<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-876077106867749026</id><updated>2013-04-25T18:47:33.900-07:00</updated><category term='Resharper'/><category term='Knockout.js'/><category term='Presentación'/><category term='Mocking'/><category term='MVC'/><category term='XP'/><category term='ContinuousIntegration'/><category term='Sonar'/><category term='Refactoring'/><category term='ASP.NET'/><category term='ASP.NET Web API'/><category term='TDD'/><category term='Agile'/><category term='CSS3'/><category term='WebTesting'/><category term='Scrum'/><category term='MsBuild'/><category term='UnitTesting'/><category term='DBTesting'/><category term='NHibernate'/><category term='StructureMap'/><category term='Spring.NET'/><category term='IOC'/><category term='DDD'/><category term='Teamcity'/><category term='CodingDojo'/><category term='Entity Framework'/><category term='HTML5'/><title type='text'>Snahider's Blog</title><subtitle type='html'>Faith Driven Development</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://snahider.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default?start-index=26&amp;max-results=25'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>30</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-1610661700510923984</id><published>2013-03-07T03:20:00.001-08:00</published><updated>2013-03-07T03:23:46.811-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CodingDojo'/><category scheme='http://www.blogger.com/atom/ns#' term='TDD'/><title type='text'>Coding Dojo Lima - Febrero 2013</title><content type='html'>&lt;p align="justify"&gt;El jueves 21 de Febrero se realizó una nuevo Coding Dojo en las oficinas de &lt;a href="http://openedgetech.com/" target="_blank"&gt;Open Edge.&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Los &lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?WhatIsCodingDojo" target="_blank"&gt;Coding Dojo&lt;/a&gt; son eventos que se realizan periódicamente en distintas ciudades al rededor del mundo y reúnen a los desarrolladores de todas las plataformas para trabajar en un reto de programación (&lt;a href="http://en.wikipedia.org/wiki/Kata_(programming)" target="_blank"&gt;Code Kata&lt;/a&gt;). El objetivo es divertirse, discutir y aprender entre todos nuevas habilidades de programación.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/-zZCbVdFDCz4/UTh4CX_nhLI/AAAAAAAAAh0/AQl5a61bfx4/s1600-h/codingdojo1%25255B8%25255D.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="codingdojo1" border="0" alt="codingdojo1" src="http://lh3.ggpht.com/-Q4nOMXDDXgU/UTh4Da0BzVI/AAAAAAAAAh8/EbshMHy7HlQ/codingdojo1_thumb%25255B3%25255D.jpg?imgmax=800" width="648" height="487" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;En esta oportunidad escogimos el &lt;a href="http://codingdojo.org/cgi-bin/wiki.pl?KataPotter" target="_blank"&gt;kata Potter&lt;/a&gt;, que consisten implementar un programa que calcule el óptimo descuento para cualquier combinación de compra de libros&amp;#160; de la saga de Harry Potter, donde existen diferentes reglas de descuentos de acuerdo a los libros comprados.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/-gDHMj06CSqg/UTh4ERLLX_I/AAAAAAAAAiE/PMY5UNamwvU/s1600-h/codingdojo2%25255B3%25255D.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="codingdojo2" border="0" alt="codingdojo2" src="http://lh4.ggpht.com/-Hk_ORu6mUkA/UTh4FIZb-tI/AAAAAAAAAiM/PA1bTMAVAAU/codingdojo2_thumb%25255B1%25255D.jpg?imgmax=800" width="648" height="487" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Asimismo se realizaron entrevistas a los asistentes y facilitadores para recoger sus opiniones sobre el Coding Dojo, podemos observarlas en el siguiente video. &lt;/p&gt; &lt;iframe height="360" src="http://www.youtube.com/embed/ftOljmo1nPI?rel=0" frameborder="0" width="640" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;  &lt;p align="justify"&gt;Muchas gracias a Pamela (&lt;a href="https://twitter.com/pamcdm" target="_blank"&gt;@pamcdm&lt;/a&gt;) por las entrevistas, grabación y edición de este fabuloso video.&lt;/p&gt;  &lt;p align="justify"&gt;Todos los materiales utilizados se pueden &lt;a href="https://github.com/snahider/Coding-Dojo/tree/master/Randori" target="_blank"&gt;descargar aquí.&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Hasta el próximo Coding Dojo, estén atentos a la inscripción que será publicada en la lista de &lt;a href="https://groups.google.com/forum/#!forum/agileperu" target="_blank"&gt;Agile Perú.&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;Saludos   &lt;br /&gt;&lt;a href="https://twitter.com/snahider" target="_blank"&gt;@Snahider&lt;/a&gt;&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/1610661700510923984'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/1610661700510923984'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2013/03/coding-dojo-lima-febrero-2013.html' title='Coding Dojo Lima - Febrero 2013'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/-Q4nOMXDDXgU/UTh4Da0BzVI/AAAAAAAAAh8/EbshMHy7HlQ/s72-c/codingdojo1_thumb%25255B3%25255D.jpg?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-2011772168208588101</id><published>2012-09-07T11:50:00.001-07:00</published><updated>2013-04-07T23:41:03.592-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='UnitTesting'/><category scheme='http://www.blogger.com/atom/ns#' term='WebTesting'/><category scheme='http://www.blogger.com/atom/ns#' term='Mocking'/><category scheme='http://www.blogger.com/atom/ns#' term='DBTesting'/><title type='text'>Test Automation .NET</title><content type='html'>Les comparto los materiales que utilizo para facilitar talleres de &amp;quot;Test Automation .NET&amp;quot;, para que todos puedan aprovecharlos en sus comunidades o trabajo.&amp;#160; &lt;br /&gt;  &lt;ul&gt;   &lt;li&gt;Materiales completos (source code, slides, docs): &lt;a href="https://github.com/snahider/Test-Automation-NET"&gt;https://github.com/snahider/Test-Automation-NET&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Descripción del taller: &lt;a href="http://www.openedgetech.com/calendario/490-pruebas-automatizadas-net"&gt;http://www.openedgetech.com/calendario/490-pruebas-automatizadas-net&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Slides: &lt;a href="http://www.slideshare.net/snahider/test-automation-net"&gt;http://www.slideshare.net/snahider/test-automation-net&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Licencia: &lt;a href="http://creativecommons.org/licenses/by-sa/3.0/"&gt;Creative Commons Attribution-ShareAlike 3.0 Unported License&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;iframe style="border-bottom: #ccc 0px solid; border-left: #ccc 1px solid; margin-bottom: 5px; border-top: #ccc 1px solid; border-right: #ccc 1px solid" height="356" marginheight="0" src="http://www.slideshare.net/slideshow/embed_code/14206339" frameborder="0" width="427" marginwidth="0" scrolling="no" allowfullscreen="allowfullscreen"&gt; &lt;/iframe&gt;    &lt;br /&gt;No es una guía paso a paso pero creo que cualquiera podrá entenderlos.     &lt;br /&gt;Si pueden brindar algún tipo de feedback o contribución sería buenísimo.&lt;/p&gt;  &lt;p&gt;Espero les sea de utilidad.    &lt;br /&gt;Saludos     &lt;br /&gt;&lt;a href="https://twitter.com/Snahider" target="_blank"&gt;@Snahider&lt;/a&gt;&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/2011772168208588101'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/2011772168208588101'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2012/09/test-automation-net.html' title='Test Automation .NET'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-9170713316387491930</id><published>2012-08-10T14:48:00.001-07:00</published><updated>2012-08-10T14:59:00.824-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Refactoring'/><category scheme='http://www.blogger.com/atom/ns#' term='Resharper'/><title type='text'>Cómo aprender a utilizar Resharper</title><content type='html'>&lt;table border="0" cellspacing="0" cellpadding="0" width="100%"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td style="vertical-align: bottom" valign="top" width="635"&gt;         &lt;p align="justify"&gt;Resharper es un complemento indispensable para aquellos que utilizamos Visual Studio, ya que provee una gran cantidad de funcionalidad que potencia el IDE e incrementa notablemente la productividad del desarrollador.&lt;/p&gt;          &lt;p align="justify"&gt;Debido a que cada vez son los más desarrolladores y empresas que utilizamos esta herramienta, se escucha bastante la pregunta &lt;strong&gt;“¿Cómo puedo aprender yo y mi equipo a utilizar bien Resharper ?”&lt;/strong&gt;. &lt;/p&gt;       &lt;/td&gt;        &lt;td valign="top" width="179"&gt;&lt;a href="http://lh6.ggpht.com/-3mgABVhyM5Y/UCWBniZSDAI/AAAAAAAAAg0/NhKxKCwboyg/s1600-h/Resharper_Peque%2525C3%2525B1o%25255B4%25255D.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Resharper_Pequeño" border="0" alt="Resharper_Pequeño" src="http://lh4.ggpht.com/-ACaeTlCJcI0/UCWBoS3N4pI/AAAAAAAAAg8/mhyMIafL96I/Resharper_Peque%2525C3%2525B1o_thumb%25255B2%25255D.jpg?imgmax=800" width="235" height="169" /&gt;&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p align="justify"&gt;Les comparto estos consejos y recursos de aprendizaje que los ayudarán a dominar esta increíble herramienta.&lt;/p&gt;  &lt;ol&gt;   &lt;li style="margin-bottom: 20px"&gt;     &lt;div align="justify"&gt;&lt;a href="http://blog.pluralsight.com/2011/08/25/free-pluralsight-training-for-resharper-customers/" target="_blank"&gt;Free Pluralsight Training for ReSharper Customers&lt;/a&gt;: Si ya han adquirido la licencia de R#, seguramente les ha llegado un email con una suscripción por un mes para la capacitación online &lt;a href="http://www.pluralsight.com/training/courses/tableofcontents?courseName=resharperfundamentals" target="_blank"&gt;Resharper Fundamentals&lt;/a&gt;; consiste en casi 4 horas de videos separados por capítulos sobre las diversas características de R# que permiten mejorar nuestra productividad. &lt;/div&gt;   &lt;/li&gt;    &lt;li style="margin-bottom: 20px"&gt;     &lt;div align="justify"&gt;Si no tienen tiempo para ver las 4 horas, también pueden ver la estupenda &lt;a href="http://www.altnethispano.org/wiki/van-2010-07-31-resharper.ashx" target="_blank"&gt;VAN sobre Resharper&lt;/a&gt; de la comunidad &lt;a href="http://www.altnethispano.org" target="_blank"&gt;Alt.Net Hispano&lt;/a&gt;, es un webinar de 2 horas donde se muestran diversos casos de uso donde se puede aprovechar al máximo R#.         &lt;br /&gt;        &lt;br /&gt;Asimismo, la comunidad Alt.Net Hispano tiene una &lt;a href="http://altnethispano.org/reuniones/historico.aspx" target="_blank"&gt;gran cantidad de webinars grabados&lt;/a&gt; sobre temas como Agile, .NET, Arquitectura, Patrones de Software, etc. &lt;/div&gt;   &lt;/li&gt;    &lt;li style="margin-bottom: 20px"&gt;     &lt;div align="justify"&gt;Algunas de las funcionalidades más útiles e impresionantes de R# se encuentran a nivel de &lt;a href="http://www.jetbrains.com/resharper/features/code_generation.html" target="_blank"&gt;Generación de Código&lt;/a&gt;, &lt;a href="http://www.jetbrains.com/resharper/features/code_refactoring.html" target="_blank"&gt;Refactoring&lt;/a&gt; y &lt;a href="http://www.jetbrains.com/resharper/features/unit_testing.html" target="_blank"&gt;Pruebas Unitarias&lt;/a&gt;. Si quieren perfeccionar el uso de estas funcionalidades les recomiendo realizar algún Kata de Refactoring, uno muy bueno es el &lt;a href="http://snahider.blogspot.com/2011/10/refactoring-gumball-machine.html" target="_blank"&gt;Gumball Machine Kata&lt;/a&gt; ya que adicionalmente los ayudará a practicar sobre Code Smells y Desing Patterns, pueden practicarlos por sí mismos o realizar un taller dirigido junto con todo tu equipo. &lt;/div&gt;   &lt;/li&gt;    &lt;li style="margin-bottom: 20px"&gt;     &lt;div align="justify"&gt;Tener a la mano los Hotkeys (&lt;a href="http://www.jetbrains.com/resharper/docs/ReSharper70DefaultKeymap_VS_scheme.pdf" target="_blank"&gt;VS Scheme&lt;/a&gt; o &lt;a href="http://www.jetbrains.com/resharper/docs/ReSharper70DefaultKeymap_IDEA_scheme.pdf" target="_blank"&gt;IDEA Scheme&lt;/a&gt;) y utilizarlos siempre que se pueda. Les recomiendo imprimirlos o guardarlos en un marcador dentro del navegador. Cuando estén programando y utilicen el mouse pregúntense ¿cómo podría haber hecho lo mismo utilizando un shortcut?.         &lt;br /&gt;        &lt;br /&gt;Utilizar los shortcuts del teclado nos permiten trabajar mucho más rápido y distraernos menos. Toda la funcionalidad de R# combinada con los shortcuts puede incrementar muchísimo la productividad. &lt;/div&gt;   &lt;/li&gt;    &lt;li style="margin-bottom: 20px"&gt;     &lt;div align="justify"&gt;Para reforzar el uso y la práctica de R# les recomiendo asistir a &lt;a href="http://codingdojo.org/" target="_blank"&gt;Coding Dojos&lt;/a&gt; u organizarlos de manera interna en su empresa. Adicionalmente, les aconsejo elegir una kata sencilla y utilizar como restricción que &lt;em&gt;“no está permitido utilizar el mouse”&lt;/em&gt;, pueden dividir el Coding Dojo en 2 sesiones consecutivas: la primera realizando el kata normalmente y la segunda utilizando la restricción. &lt;/div&gt;   &lt;/li&gt;    &lt;li style="margin-bottom: 20px"&gt;     &lt;div align="justify"&gt;De más está decir que la &lt;a href="http://www.jetbrains.com/resharper/documentation/index.jsp" target="_blank"&gt;documentación&lt;/a&gt; es una muy buena fuente de consulta. &lt;/div&gt;   &lt;/li&gt;    &lt;li style="margin-bottom: 20px"&gt;     &lt;div align="justify"&gt;Busquen en su comunidad personas con quienes puedan compartir conocimiento o algún &lt;a href="http://openedgetech.com/" target="_blank"&gt;Partner local&lt;/a&gt; de JetBrains que pueda brindar capacitación y consultoría a su empresa.&lt;/div&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p align="justify"&gt;Espero que les sea de mucha utilidad. &lt;/p&gt;  &lt;p align="justify"&gt;Saludos,    &lt;br /&gt;&lt;a href="https://twitter.com/Snahider" target="_blank"&gt;@Snahider&lt;/a&gt;&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/9170713316387491930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/9170713316387491930'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2012/08/como-aprender-utilizar-resharper.html' title='Cómo aprender a utilizar Resharper'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/-ACaeTlCJcI0/UCWBoS3N4pI/AAAAAAAAAg8/mhyMIafL96I/s72-c/Resharper_Peque%2525C3%2525B1o_thumb%25255B2%25255D.jpg?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-4269137980234136273</id><published>2012-08-06T12:15:00.001-07:00</published><updated>2012-08-07T06:52:32.192-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CSS3'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML5'/><title type='text'>Videos para aprender HTML5 y CSS3</title><content type='html'>&lt;p align="justify"&gt;Hola a todos, les comparto una serie de 21 videos gratuitos que nos enseñaran los fundamentos de HTML5 y CSS3.&amp;#160; &lt;/p&gt;  &lt;p align="justify"&gt;Desde &lt;a href="http://channel9.msdn.com/Series/HTML5-CSS3-Fundamentals-Development-for-Absolute-Beginners" target="_blank"&gt;aquí&lt;/a&gt; podemos acceder a los videos y al código fuente de los ejercicios, estos se encuentran alojados en Channel 9 por lo que podremos descargarlos o verlos online. &lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/-jXIzmcytcCM/UCAYvwmjQ3I/AAAAAAAAAbo/8tVnl98zHBc/s1600-h/HTML5%25255B3%25255D.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="HTML5" border="0" alt="HTML5" src="http://lh3.ggpht.com/-A1qYS1YcXzE/UCAYxaMFGqI/AAAAAAAAAbw/mGvNZPc0N2w/HTML5_thumb%25255B1%25255D.jpg?imgmax=800" width="761" height="217" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Los videos han sido realizados por &lt;a href="http://channel9.msdn.com/Niners/Bob_Tabor" target="_blank"&gt;Bob Tabor&lt;/a&gt; que es muy conocido por crear otros varios &lt;a href="http://www.learnvisualstudio.net/" target="_blank"&gt;recursos de aprendizaje sobre la plataforma .NET.&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Saludos,    &lt;br /&gt;&lt;a href="https://twitter.com/snahider" target="_blank"&gt;@Snahider&lt;/a&gt;&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/4269137980234136273'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/4269137980234136273'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2012/08/videos-para-aprender-html5-y-css3.html' title='Videos para aprender HTML5 y CSS3'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/-A1qYS1YcXzE/UCAYxaMFGqI/AAAAAAAAAbw/mGvNZPc0N2w/s72-c/HTML5_thumb%25255B1%25255D.jpg?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-1259470338546060780</id><published>2012-07-30T04:11:00.001-07:00</published><updated>2012-08-12T21:46:48.191-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Knockout.js'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>Single Page Applications – Parte 5 – Comunicación entre ViewModels</title><content type='html'>&lt;p&gt;En este post veremos como comunicar las 2 vistas que hemos creado anteriormente(Seleccionar Producto e Ingresar Pedido), de tal manera que cuando seleccionemos un producto en la primera pantalla, desaparezca esta pantalla y se muestre la pantalla de ingreso de pedido con los datos del producto seleccionado.&lt;/p&gt;  &lt;p&gt;Para lograr que nuestros 2 viewmodels se comuniquen tenemos las siguientes opciones: crear un objeto padre que se encargue de coordinar todas los view models; utilizar las urls, hasbangs (#!) y routing; o utilizar el patrón publish/suscribe entre las vistas. &lt;/p&gt;  &lt;p&gt;En esta oportunidad utilizaremos un objeto padre para coordinar todos los viewmodels del proceso de delivery, pero en los siguientes posts veremos las otras alternativas. &lt;/p&gt;  &lt;p&gt;Implementamos este objeto dentro del archivo &lt;em&gt;/Scripts/App&lt;font size="2"&gt;/&lt;/font&gt;ViewModels/deliveryviewmodel.js&lt;/em&gt;, este objeto tendrá una propiedad por cada uno de los viewmodels que esté coordinando.&lt;/p&gt;  &lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; DeliveryViewModel = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; self = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;;&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.chooseProduct = ko.observable();&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.placeOrder = ko.observable();&lt;br /&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;Asimismo, este objeto tendrá métodos que serán responsables de mostrar cada una de las vistas del proceso de delivery.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; DeliveryViewModel = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; self = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.chooseProduct = ko.observable();&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.placeOrder = ko.observable();&lt;br /&gt; &lt;br /&gt;&lt;font style="background-color: #ffff00"&gt;&amp;#160;&amp;#160;&amp;#160; self.showChooseProduct = &lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00" color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#006400"&gt;//&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#00008b"&gt;&lt;strong&gt;TODO: Mostrar la primera vista y ocultar las demás&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.showPlaceOrder = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#000000"&gt; (productId) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#006400"&gt;//&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#00008b"&gt;&lt;strong&gt;TODO: Mostrar la segunda vista y ocultar las demás&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.showConfirmation = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#006400"&gt;//&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#00008b"&gt;&lt;strong&gt;TODO: Mostrar la tercera vista y ocultar las demás&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&lt;font style="background-color: #ffff00"&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.showChooseProduct();&lt;/font&gt;&lt;br /&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;Los viewmodels ChooseProductViewModel y PlaceOrderViewModel dependerán este nuevo objeto padre y le delegarán la responsabilidad de mostrar la vista adecuada.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; ChooseProductViewModel = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (&lt;font style="background-color: #ffff00"&gt;parent&lt;/font&gt;) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; self = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.products = ko.observableArray();&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.goToPlaceOrder = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (product) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font style="background-color: #ffff00"&gt;parent.showPlaceOrder(product.id);&lt;/font&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.init = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ProductsDataSource.getAll(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; (data) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; self.products(data);&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.init();&lt;br /&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="line-height: normal; font-family: ; background: white"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; PlaceOrderViewModel = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (productId, &lt;font style="background-color: #ffff00"&gt;parent&lt;/font&gt;) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; self = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.order = ko.observable();&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.postOrder = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OrdersDataSource.create(self.order, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font style="background-color: #ffff00"&gt;parent.showConfirmation();&lt;br /&gt;&lt;/font&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.init = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ProductsDataSource.get(productId, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; (product) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; self.order(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; Order(product));&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.init();&lt;br /&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;El objeto &lt;em&gt;DeliveryViewModel&lt;/em&gt;, cada vez que los objetos hijos le delegen mostrar una nueva vista, instanciará el viewmodel adecuado para esta vista.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; DeliveryViewModel = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; self = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.chooseProduct = ko.observable();&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.placeOrder = ko.observable();&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.showChooseProduct = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&lt;font style="background-color: #ffff00"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; self.chooseProduct(&lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00" color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#000000"&gt; ChooseProductViewModel(self));&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; self.placeOrder(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;null&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="background-color: #ffff00"&gt;);&lt;/font&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.showPlaceOrder = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (productId) {&lt;br /&gt;&lt;font style="background-color: #ffff00"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; self.chooseProduct(&lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00" color="#0000ff"&gt;null&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#000000"&gt;);&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; self.placeOrder(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="background-color: #ffff00"&gt; PlaceOrderViewModel(productId, self));&lt;/font&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.showConfirmation = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#006400"&gt;//&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#00008b"&gt;&lt;strong&gt;TODO: Mostrar la Tercera vista y ocultar las demás&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.showChooseProduct();&lt;br /&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;Podemos observar que para ocultar una vista simplemente asignamos &lt;em&gt;null&lt;/em&gt; a la propiedad, esto se debe a que &lt;em&gt;Knockoutjs&lt;/em&gt; automáticamente eliminará toda la sección HTML si es que el valor del binding es &lt;em&gt;null&lt;/em&gt;.&lt;/p&gt;

&lt;p align="justify"&gt;Necesitamos enlazar toda la aplicación al nuevo objeto &lt;em&gt;DeliveryViewModel, &lt;/em&gt;para esto modificamos el archivo &lt;em&gt;/Scripts/application.js &lt;/em&gt;donde se inicializan los viewmodels.&lt;/p&gt;

&lt;p&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff" face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;function&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; initializeApplication() { 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; initializeViewModels(); 

        &lt;br /&gt;} 

        &lt;br /&gt;&lt;/font&gt;

      &lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; initializeViewModels() { 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;font style="background-color: #ffff00"&gt;ko.applyBindings(&lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00" color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&lt;font style="background-color: #ffff00"&gt; DeliveryViewModel());&lt;/font&gt; 

        &lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Enlazamos cada vista de manera individual a una propiedad del &lt;em&gt;DeliveryViewModel&lt;/em&gt;, para esto modificamos el archivo &lt;em&gt;/Views/Home/Index.cshtml.&lt;/em&gt;&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00" color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;with: chooseProduct&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;@&lt;/font&gt;&lt;/span&gt;Html.Partial(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;_ChooseProduct&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00" color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;with: placeOrder&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;@&lt;/font&gt;&lt;/span&gt;Html.Partial(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;_PlaceOrder&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;)&lt;/font&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; $(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; initializeApplication();&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; });&lt;/font&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 12pt" color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;Por último agregamos las referencias a todos los nuevos scripts dentro del archivo &lt;em&gt;/Views/Shared/Layout.cshtml.&lt;/em&gt;&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/Lib/jquery-1.6.2.min.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/Lib/knockout-2.1.0.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/App/Data/productsdatasource.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/App/Data/ordersdatasource.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/App/Models/order.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font style="background-color: #ffff00"&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/App/ViewModels/deliveryviewmodel.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/App/ViewModels/chooseproductviewmodel.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/App/ViewModels/placeorderviewmodel.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/application.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;Si ejecutamos la aplicación podremos ver el listado de productos.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh4.ggpht.com/-8Q2hbLXnT1g/UBZrwI4NK2I/AAAAAAAAAas/t4LdkIpL2bU/s1600-h/ChooseProd_Small%25255B5%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="ChooseProd_Small" border="0" alt="ChooseProd_Small" src="http://lh4.ggpht.com/-i4K7fyRWsS4/UBZr1i4DHOI/AAAAAAAAAa0/ZNaQ_3FxRf8/ChooseProd_Small_thumb%25255B3%25255D.png?imgmax=800" width="489" height="342" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Si seleccionamos alguno de los productos aparecerá la pantalla para completar los datos de la orden.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh3.ggpht.com/-k-j4aYzijRU/UBZr669ZVtI/AAAAAAAAAa8/uljf1MiOV08/s1600-h/placeorder%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="placeorder" border="0" alt="placeorder" src="http://lh4.ggpht.com/-vk8FHS96kPY/UBZr-svD3dI/AAAAAAAAAbE/JRfhocwzIdQ/placeorder_thumb%25255B1%25255D.png?imgmax=800" width="579" height="291" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;En el siguiente post veremos la tercera pantalla del proceso de delivery.&lt;/p&gt;

&lt;p&gt;Saludos 
  &lt;br /&gt;Angel Núñez Salazar&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/1259470338546060780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/1259470338546060780'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2012/07/single-page-applications-parte-5.html' title='Single Page Applications – Parte 5 – Comunicación entre ViewModels'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/-i4K7fyRWsS4/UBZr1i4DHOI/AAAAAAAAAa0/ZNaQ_3FxRf8/s72-c/ChooseProd_Small_thumb%25255B3%25255D.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-8325971360421509821</id><published>2012-07-20T19:47:00.001-07:00</published><updated>2012-08-12T21:33:21.639-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Knockout.js'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>Single Page Applications – Parte 4 – Más KnockoutJS</title><content type='html'>&lt;p&gt;En este post vamos a implementar la segunda pantalla de nuestra panadería online.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Pantalla: Ingresar Pedido&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Pantalla a través de la cuál un usuario ingresa los datos del pedido para que este sea enviado a la dirección especificada.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-KybOJ-ApMsQ/UAoYR-fAZbI/AAAAAAAAAaA/hlIYUSZVHR8/s1600-h/PlaceOrder3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="PlaceOrder" border="0" alt="PlaceOrder" src="http://lh4.ggpht.com/-UE2UdzkNOlc/UAoYTObBsmI/AAAAAAAAAaI/JL7dgRqArpM/PlaceOrder_thumb1.png?imgmax=800" width="580" height="296" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Creamos el ViewModel para esta pantalla dentro del archivo &lt;em&gt;/Scripts/App/ViewModels/placeorderviewmodel.js&lt;/em&gt;. Este ViewModel recibirá como parámetro el código del producto seleccionado para el pedido.&lt;/p&gt;  &lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; PlaceOrderViewModel = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (productId) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; self = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.order = ko.observable();&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.postOrder = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OrdersDataSource.create(self.order, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#006400"&gt;//&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#00008b"&gt;&lt;strong&gt;TODO: Ir a la pantalla de confirmación&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;&lt;br /&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;Delegamos la creación de la orden al objeto &lt;em&gt;OrdersDataSource&lt;/em&gt; y lo implementamos dentro del archivo &lt;em&gt;/Scripts/App/Data/ordersdatasource.js.&lt;/em&gt;&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; OrdersDataSource = (&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; create: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (order, success) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $.ajax({&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; type: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;POST&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; url: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;/api/orders&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dataType: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;json&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; contentType: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;application/json;charset=utf-8&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;,&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; data: ko.toJSON(order),&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; success: success&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt;} ());&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;Completamos el código del &lt;em&gt;PlaceOrderViewModel&lt;/em&gt; para cargar los datos del producto que serán mostrados en el formulario de la orden.&lt;/p&gt;

&lt;p&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; PlaceOrderViewModel = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (productId) { 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; self = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;; 
        &lt;br /&gt;

        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.order = ko.observable(); 

        &lt;br /&gt;

        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.postOrder = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () { 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OrdersDataSource.create(self.order, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () { 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#006400"&gt;//&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#00008b"&gt;&lt;strong&gt;TODO: Ir a la pantalla de confirmación&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt; 

      &lt;br /&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }); 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }; 

        &lt;br /&gt;

        &lt;br /&gt;&lt;font style="background-color: #ffff00"&gt;&amp;#160;&amp;#160;&amp;#160; self.init = &lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00" color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#000000"&gt; () { 
          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ProductsDataSource.get(productId, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#000000"&gt; (product) { 
          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#006400"&gt;//&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#00008b"&gt;&lt;strong&gt;TODO: Crear una instancia de la Orden con los datos del producto&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&lt;font style="background-color: #ffff00"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }); 
          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }; 

          &lt;br /&gt;

          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.init();&lt;/font&gt; 

        &lt;br /&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;Agregamos un nuevo método dentro del objeto &lt;em&gt;ProductsDataSource&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; ProductsDataSource = (&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () { 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; { 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; getAll: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (success) { 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $.ajax({ 

        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; type: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;GET&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;, 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; url: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;/api/products&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;, 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; contentType: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;application/json;charset=utf-8&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;, 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dataType: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;json&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;, 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; success: success 

        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }); 

        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }, 

        &lt;br /&gt;&lt;font style="background-color: #ffff00"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get: &lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00" color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#000000"&gt; (id, success) { 
          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $.ajax({ 

          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; type: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;GET&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#000000"&gt;, 
          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; url: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;/api/products/&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#000000"&gt; + id, 
          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; contentType: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;application/json;charset=utf-8&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#000000"&gt;, 
          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dataType: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;json&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&lt;font style="background-color: #ffff00"&gt;, 
          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; success: success 

          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }); 

          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt; 

        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }; 

        &lt;br /&gt;} ());&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Creamos la clase &lt;em&gt;Order&lt;/em&gt;&amp;#160; dentro del archivo &lt;em&gt;/Scripts/App/Models/order.js&lt;/em&gt;, esta clase contendrá los datos del pedido que serán enviados al servicio REST.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; Order = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (product) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; self = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.address = ko.observable();&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.email = ko.observable();&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.quantity = ko.observable(1);&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.productId = product.id;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.product = product;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.total = ko.computed(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; (self.product.price * self.quantity()).toFixed(2);&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; });&lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;Utilizamos la sentencia &lt;em&gt;ko.observable()&lt;/em&gt; para relacionar las propiedades de esta clase con los campos del formulario. También utilizamos la sentencia &lt;em&gt;ko.computed()&lt;/em&gt; para crear una función observable que dependa de otros observables, esto permitirá que el monto total de la orden se actualice automáticamente cuando el valor de la cantidad cambie. &lt;/p&gt;

&lt;p align="justify"&gt;Completamos el código del &lt;em&gt;PlaceOrderViewModel&lt;/em&gt; para instanciar una nueva orden apenas se reciba los datos del producto.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; PlaceOrderViewModel = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (productId) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; self = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.order = ko.observable();&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.postOrder = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; OrdersDataSource.create(self.order, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#006400"&gt;//&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#00008b"&gt;&lt;strong&gt;TODO: Ir a la pantalla de confirmación&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.init = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ProductsDataSource.get(productId, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; (product) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;font style="background-color: #ffff00"&gt;self.order(&lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00" color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&lt;font style="background-color: #ffff00"&gt; Order(product));&lt;/font&gt;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.init();&lt;br /&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;Creamos la vista parcial &lt;em&gt;/Views/Home/_PlaceOrder.cshtml&lt;/em&gt; y agregamos el código HTML correspondiente esta pantalla.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white"&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="color: "&gt;&lt;font color="#006400"&gt;&amp;lt;!-- ko with: order --&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;h1&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text: 'Place Your Order: '+product.name&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;h1&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;form&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;action&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;method&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;post&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;fieldset&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;no-legend&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;legend&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;Place Your Order&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;legend&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;img&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;product-image order-image&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;quot;attr:{ src:'/content/images/products/thumbnails/' + product.imagename, &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; alt:product.name }&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;/&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;ol&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;li&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;label&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;for&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;orderEmail&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;Your Email Address&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;label&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;input&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;orderEmail&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;name&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;orderEmail&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;value:email&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;/&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;li&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;li&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;label&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;for&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;orderShipping&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;Shipping Address&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;label&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;textarea&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;rows&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;4&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;cols&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;20&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;orderShipping&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;name&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;orderShipping&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;value:address&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;textarea&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;li&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;li&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;quantity&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;label&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;for&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;orderQty&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;Quantity&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;label&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;input&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;quantity&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;name&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;quantity&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;value:quantity, valueUpdate: 'afterkeydown'&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;/&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; x &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;span&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;orderPrice&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text:product.price&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;span&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;span&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;orderTotal&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text:total()&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;span&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;li&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;ol&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;p&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;input&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;submit&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;value&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;Place Order&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;click:$parent.postOrder&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;/&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;p&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;fieldset&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;form&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#006400"&gt;&amp;lt;!-- /ko –&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;Examinemos brevemente los nuevos “bindings” que estamos utilizando.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;with:&lt;/strong&gt; Crea un “contexto” dentro del cuál todos los bindings hacen referencia al objeto asignado. Una característica de este binding es que lo podemos utilizarlo dentro de un comentario sin la necesidad de crear un nuevo tag. &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;value:&lt;/strong&gt; Asocia el atributo “value” con el valor de una propiedad dentro del ViewModel. Típicamente usado con elementos dentro de un formulario como: &amp;lt;input&amp;gt;, &amp;lt;select&amp;gt;, &amp;lt;textarea&amp;gt;, etc. &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;valueUpdate:&lt;/strong&gt; Por defecto los bindings se actualizan cuando se el usuario cambia el foco del elemento. Esta propiedad nos permite controlar cuando se actualizarán los cambios, por ejemplo: “afterkeydown”, “keyup”, “keypress”, etc. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Desde el archivo &lt;em&gt;/Views/Home/Index.cshtml &lt;/em&gt;hacemos referencia a la vista parcial recién creada.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;@&lt;/font&gt;&lt;/span&gt;Html.Partial(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;_ChooseProduct&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;);&lt;/font&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;br /&gt;&lt;font style="background-color: #ffff00"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%"&gt;@&lt;/span&gt;Html.Partial(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;_PlaceOrder&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;);&lt;/font&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; $(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; initializeApplication();&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; });&lt;/font&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 12pt" color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;Agregamos las referencias de los nuevos scripts dentro del archivo /Views/Shared/Layout.cshtml.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/Lib/jquery-1.6.2.min.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/Lib/knockout-2.1.0.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/App/Data/productsdatasource.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font style="background-color: #ffff00"&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/App/Data/ordersdatasource.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/App/Models/order.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/App/ViewModels/chooseproductviewmodel.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font style="background-color: #ffff00"&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/App/ViewModels/placeorderviewmodel.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/application.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;Luego de todos estos cambios, la estructura final de archivos ha quedado de la siguiente manera.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh6.ggpht.com/-Tn5AxRhcJ7I/UAoYTvmZgjI/AAAAAAAAAaQ/CIPv0-Egahs/s1600-h/structureSP43.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="structureSP4" border="0" alt="structureSP4" src="http://lh6.ggpht.com/-3qretWCLH6Q/UAoYUUsGIII/AAAAAAAAAaY/rJvGTpS5NJg/structureSP4_thumb1.png?imgmax=800" width="272" height="349" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;En el siguiente post veremos como comunicar nuestros 2 ViewModels para permitir que la segunda vista recién se muestre luego de seleccionado un producto.&lt;/p&gt;

&lt;p&gt;Saludos 
  &lt;br /&gt;Angel Núñez Salazar&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/8325971360421509821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/8325971360421509821'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2012/07/single-page-applications-parte-4.html' title='Single Page Applications – Parte 4 – Más KnockoutJS'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/-UE2UdzkNOlc/UAoYTObBsmI/AAAAAAAAAaI/JL7dgRqArpM/s72-c/PlaceOrder_thumb1.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-802125770402017592</id><published>2012-05-27T19:02:00.001-07:00</published><updated>2012-08-12T21:28:58.900-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Knockout.js'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>Single Page Applications – Parte 3 – UI Patterns, KnockoutJS</title><content type='html'>&lt;p align="justify"&gt;En esta oportunidad vamos a hablar sobre como estructurar la aplicación y como organizar el código. Los patrones más comúnmente usados para organizar aplicaciones en el “front-end” son 2: MVC y MVVM.&lt;/p&gt;  &lt;h4&gt;MVC en Javascript&lt;/h4&gt;  &lt;p&gt;MVC es probablemente el patrón de presentación más antiguo que existe y es utilizado en múltiples lenguajes de programación. Dentro de Javascript existen las siguientes implementaciones:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://documentcloud.github.com/backbone/" target="_blank"&gt;Backbone.js&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://javascriptmvc.com/" target="_blank"&gt;JavaScriptMVC&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://sammyjs.org/" target="_blank"&gt;Sammy.js&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://spinejs.com/" target="_blank"&gt;Spine&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Examinemos los componentes de este patrón dentro de Javascript:&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Models&lt;/strong&gt;: Contienen los datos que se van a manejar en la aplicación, muchas veces implementan el Observer Pattern(Publisher/Subscriber Pattern) para notificar a las vistas que necesitan actualizarse cuando se ha producido algún cambio en el modelo.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Views&lt;/strong&gt;: No necesariamente constituyen directamente el HTML que se va a mostrar, sino son los encargados de renderizar el modelo, en varios de los casos utilizando “Templates”.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Controllers&lt;/strong&gt;: Intermediarios entre las Vistas y el Modelo, coordinan la actualización del Modelo de acuerdo a los cambios producidos en las vistas y viceversa. Varias implementaciones MVC en Javascript tienen un concepto diferente de lo que es convencionalmente llamado un “Controller”, por esto podemos encontrar que la “C” puede estar representada por “Colecciones” de objetos o “Rutas” o dependiendo del caso.&lt;/p&gt;  &lt;h4 align="justify"&gt;MVVM en Javascript&lt;/h4&gt;  &lt;p align="justify"&gt;Es otro patrón que busca separar el desarrollo de la interfaz de usuario, de la lógica de la aplicación. Fue originalmente definido por Microsoft para ser usado junto con WPF, pero ha sido adoptado por otros lenguajes.&lt;/p&gt;  &lt;p align="justify"&gt;En estos últimos años se han creados algunas implementaciones de este patrón dentro de Javascript:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;&lt;a href="http://knockoutjs.com/" target="_blank"&gt;KnockoutJS&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;a href="https://github.com/kmalakoff/knockback" target="_blank"&gt;Knockback.js&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;a href="http://www.kendoui.com/documentation/framework/mvvm/overview.aspx" target="_blank"&gt;Kendo MVVM&lt;/a&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;Examinemos los componentes de este patrón dentro de Javascript:&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Models:&lt;/strong&gt; Representan la información del dominio sobre el cuál trabajará la aplicación. Dentro de este patrón, no siempre los miembros del modelo se encuentran directamente en código Javascript, muchas veces los objetos del modelo se encuentran en el lado del servidor.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Views:&lt;/strong&gt; A diferencia del patrón MVC, estas vistas son “activas” es decir no solo se encargan de mostrar los datos sino también envían al ViewModel información sobre eventos. Generalmente son documentos HTML que contienen “bindings” hacia el ViewModel.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;ViewModels:&lt;/strong&gt; Representan a las vistas, a sus datos y operaciones que se realizan sobre estas. Se mantienen sincronizados con las vistas a través de los “bindings” que funcionan en doble sentido.&lt;/p&gt;  &lt;p align="justify"&gt;Para nuestra aplicación vamos a utilizar el &lt;strong&gt;Patrón MVVM&lt;/strong&gt; junto con &lt;strong&gt;KnockoutJS.&lt;/strong&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Lo primero que haremos será agregar los scripts necesarios para usar KnockoutJS dentro del archivo &lt;em&gt;/Views/Shared/Layout.cshtml&lt;/em&gt;. KnockoutJS lo podemos descargar desde su &lt;a href="http://knockoutjs.com" target="_blank"&gt;página web&lt;/a&gt; o utilizando Nuget.&lt;/p&gt;  &lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;head&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;meta&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;charset&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;/&amp;gt;&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;meta&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;name&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;viewport&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;content&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;width=device-width&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;/&amp;gt;&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;title&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;Fourth Coffee&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;title&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;link&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;href&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Content/Site.css&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;rel&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;/&amp;gt;&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/Lib/jquery-1.6.2.min.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;
&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/Lib/knockout-2.1.0.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;
&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;head&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 12pt" color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;Creamos la siguiente estructura de directorios para nuestros archivos Javascript.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh5.ggpht.com/-CQWZHng4HJI/UAfIcDo1wCI/AAAAAAAAAZA/YW8rr4UdHQc/s1600-h/FolderStructure%25255B5%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="FolderStructure" border="0" alt="FolderStructure" src="http://lh5.ggpht.com/-ym6C9wd4KLs/UAfIc8GW7hI/AAAAAAAAAZI/Io6afoZoDPw/FolderStructure_thumb%25255B3%25255D.png?imgmax=800" width="170" height="112" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;div align="justify"&gt;App: Contendrá los archivos de la aplicación que han sido desarrollados por nosotros.. &lt;/div&gt;

    &lt;ul&gt;
      &lt;li&gt;
        &lt;div align="justify"&gt;Data: Contendrá los objetos mediante los cuales accederemos a los servicios REST.&lt;/div&gt;
      &lt;/li&gt;

      &lt;li&gt;
        &lt;div align="justify"&gt;Models: Contendrá a los objetos que constituyen el Modelo de la aplicación.&lt;/div&gt;
      &lt;/li&gt;

      &lt;li&gt;
        &lt;div align="justify"&gt;ViewModels: Contendrá a los ViewModels de la aplicación.&lt;/div&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;div align="justify"&gt;Lib: Contendrá los archivos pertenecientes a frameworks y librerías externas: Jquery, KnockoutJS, etc.&lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;Creamos el &lt;em&gt;HomeController&lt;/em&gt;, la acción &lt;em&gt;Index y el archivo /Views/Home/Index.cshtml&lt;/em&gt; sin ningún contenido. &lt;/p&gt;

&lt;p align="justify"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;HomeController&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Controller&lt;/font&gt;&lt;/span&gt; 

      &lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;{ 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ActionResult&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; Index() 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; { 

        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; View(); 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } 

        &lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Luego de esto, podremos levantar la aplicación y ver una pantalla inicial.&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh3.ggpht.com/-u87kBcnOjZU/UAeWkoG9mJI/AAAAAAAAAWA/B1zsD8w24qU/s1600-h/fourthcoffee%25255B5%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="fourthcoffee" border="0" alt="fourthcoffee" src="http://lh6.ggpht.com/-q2LnWqeMuHU/UAeWlbGt2FI/AAAAAAAAAWI/Y-GIlZ6oTYc/fourthcoffee_thumb%25255B3%25255D.png?imgmax=800" width="611" height="88" /&gt;&lt;/a&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Ahora crearemos las Vistas, Modelos y ViewModels de nuestra aplicación. En este post nos vamos a enfocar únicamente en la primera pantalla y vamos a crear los elementos necesarios para su funcionamiento.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;strong&gt;Pantalla: Selección de Producto&lt;/strong&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Pantalla a través de la cuál un usuario puede seleccionar cuál será el producto que desea comprar.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/-EhQIODZxEgs/UAeWr3-N0fI/AAAAAAAAAWQ/t41tpk3FCag/s1600-h/spa_primerapagina%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="spa_primerapagina" border="0" alt="spa_primerapagina" src="http://lh6.ggpht.com/-q6UDLZ3yjyY/UAeWwUAp9DI/AAAAAAAAAWY/hnJAPsVvG5I/spa_primerapagina_thumb%25255B2%25255D.png?imgmax=800" width="455" height="406" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Creamos el ViewModel para esta pantalla dentro del archivo &lt;em&gt;/Scripts/App/ViewModels/chooseproductviewmodel.js. &lt;/em&gt;Recordemos que un ViewModel es una representación de los datos y operaciones que se pueden realizar en la pantalla, entonces lo que vamos a encontrar en este ViewModel será una propiedad que representé al “Listado de “Productos” que vamos a mostrar en la pantalla y una función que nos permita gestionar el click al botón “Order Now”.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; ChooseProductViewModel = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; self = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.products = &lt;font style="background-color: #ffff00"&gt;ko.observableArray();&lt;/font&gt;&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.goToPlaceOrder = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (product) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#006400"&gt;//&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#00008b"&gt;&lt;strong&gt;TODO: Mostrar la vista para ingresar la orden de compra del producto&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#006400"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;&lt;br /&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;Podemos observar la sentencia &lt;em&gt;ko.observableArray()&lt;/em&gt;, de esta manera le indicamos a &lt;em&gt;KnockoutJS&lt;/em&gt; que cree una sincronización en doble sentido entre la propiedad y la vista. Si el valor de una propiedad “observable” es actualizado en el ViewModel este se verá automáticamente reflejado en la vista; de la misma manera, si este valor es cambiado en la vista, este se actualizará automáticamente dentro del ViewModel.&lt;/p&gt;

&lt;p align="justify"&gt;Completamos el código del &lt;em&gt;ChooseProductViewModel&lt;/em&gt; para cargar los productos desde los servicios REST.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; ChooseProductViewModel = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; self = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.products = ko.observableArray();&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.goToPlaceOrder = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (product) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#006400"&gt;//&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#00008b"&gt;&lt;strong&gt;TODO: Mostrar la vista para ingresar la orden de compra del producto&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#006400"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt; &lt;br /&gt;&lt;font style="background-color: #ffff00"&gt;&amp;#160;&amp;#160;&amp;#160; self.init = &lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00" color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ProductsDataSource.getAll(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&lt;font style="background-color: #ffff00"&gt; (data) {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; self.products(data);&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; };&lt;br /&gt; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; self.init();&lt;/font&gt;&lt;br /&gt;};&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;Delegamos la responsabilidad de obtener los productos al objeto &lt;em&gt;ProductsDataSource&lt;/em&gt; y lo implementamos dentro del archivo &lt;em&gt;/Scripts/App/Data/productsdatasource.js. &lt;/em&gt;Podemos observar que la función &lt;em&gt;getAll&lt;/em&gt; recibe como parámetro un ”callback” que será ejecutado cuando se reciban los datos del servicio.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;var&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; ProductsDataSource = (&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; () { 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; { 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; getAll: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (success) { 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $.ajax({ 

        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; type: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;GET&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;, 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; url: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;/api/products&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;, 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; contentType: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;application/json;charset=utf-8&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;, 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dataType: &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;&amp;quot;json&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;, 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; success: success 

        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }); 

        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; } 

        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }; 

        &lt;br /&gt;} ());&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Utilizaremos “Partial Views”&lt;em&gt; &lt;/em&gt;para organizar nuestras vistas. Creamos la vista parcial &lt;em&gt;/Views/Home/_ChooseProduct.cshtml&lt;/em&gt; y agregamos el código HTML correspondiente esta pantalla.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;ul&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;products&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;foreach: products&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;li&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;product&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;productInfo&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;h3&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text: name&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;h3&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;img&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;product-image&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;attr:{ &lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; src:'/content/images/products/thumbnails/' + imagename,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; alt:name }&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;/&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;p&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;description&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text: description&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;p&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;p&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;price&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text: price&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;p&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;a&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;order-button&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;data-bind&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;attr:{ title:name }, click:$parent.goToPlaceOrder&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Order Now&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;a&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;li&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;ul&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 12pt" color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;Podemos observar la presencia de atributos &lt;em&gt;data-bind&lt;/em&gt; dentro de los tags HTML, estos son los “bindings” a través de los cuales enlazamos los elementos de las vistas a las propiedades del ViewModel. Existen “bindings” de todo tipo: texto (value, text), apariencia (css, html, attr, style), control (foreach, if, with), etc.&lt;/p&gt;

&lt;p&gt;Examinemos brevemente los “bindings” que estamos utilizando en esta oportunidad.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;foreach:&lt;/strong&gt; Duplica una sección por cada elemento dentro del arreglo. En este caso creará un bloque “&amp;lt;li&amp;gt;&amp;lt;/li&amp;gt;” por cada producto que tengamos. &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;text:&lt;/strong&gt; Establece como texto el valor de la propiedad asociada. &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;attr:&lt;/strong&gt; Establece el valor de cualquier atributo HTML. &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;click:&lt;/strong&gt; Establece un evento que será llamado cada vez que se haga click sobre el elemento. En esta oportunidad estamos utilizando la sentencia &lt;em&gt;$parent&lt;/em&gt; para referirnos al padre del objeto producto, ya que la función &lt;em&gt;goToPlaceOrder&lt;/em&gt; se encuentra en el ViewModel. &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;Desde el archivo &lt;em&gt;/Views/Home/Index.cshtml&lt;/em&gt; hacemos referencia a la vista parcial recién creada.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;@&lt;/font&gt;&lt;/span&gt;Html.Partial(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;_ChooseProduct&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;);&lt;/font&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 12pt" color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;Necesitamos enlazar la vista al &lt;em&gt;ChooseProductViewModel, &lt;/em&gt;para esto creamos el archivo &lt;em&gt;/Scripts/application.js &lt;/em&gt;donde inicializaremos los viewmodels. Utilizaremos este archivo para configurar todo lo necesario para el funcionamiento de la aplicación.&lt;/p&gt;

&lt;p align="justify"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff" face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;function&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; initializeApplication() { 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; initializeViewModels(); 

        &lt;br /&gt;} 

        &lt;br /&gt;&lt;/font&gt;

      &lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; initializeViewModels() { 
        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ko.applyBindings(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; ChooseProductViewModel()); 
        &lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;Agregamos el siguiente script al final del archivo &lt;em&gt;/Views/Home/Index.cshtml&lt;/em&gt; para inicializar la aplicación.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;@&lt;/font&gt;&lt;/span&gt;Html.Partial(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;_ChooseProduct&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;);&lt;/font&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;br /&gt;&lt;font style="background-color: #ffff00"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; $(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;function&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; () {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; initializeApplication();&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; });&lt;/font&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 12pt" color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;Por último agregamos las referencias a todos los nuevos scripts dentro del archivo &lt;em&gt;/Views/Shared/Layout.cshtml. &lt;/em&gt;&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: ; background: white; color: "&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/Lib/jquery-1.6.2.min.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/Lib/knockout-2.1.0.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&lt;font style="background-color: #ffff00"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font style="background-color: #ffff00"&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/App/Data/productsdatasource.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/App/ViewModels/chooseproductviewmodel.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="background-color: #ffff00"&gt;&lt;font size="2"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/Scripts/application.js&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;Luego de todos estos cambios, la estructura final de archivos ha quedado de la siguiente manera.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh5.ggpht.com/-PXTJua8xC7I/UAkVyc9ys5I/AAAAAAAAAZo/Z3yIHRc0zJM/s1600-h/structureSPA3%25255B7%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="structureSPA3" border="0" alt="structureSPA3" src="http://lh3.ggpht.com/-thF9eT0bAsQ/UAkVzd8UhpI/AAAAAAAAAZw/RrtUsUbIIlA/structureSPA3_thumb%25255B3%25255D.png?imgmax=800" width="280" height="277" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Si ejecutamos la aplicación podremos observar el listado de productos.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh3.ggpht.com/-glRAaBG-GBs/T8LchBOU4-I/AAAAAAAAAU0/SlcBqkR2Pc0/s1600-h/image%25255B8%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/-FaTKQjO709U/T8Lcpp69_dI/AAAAAAAAAU8/7Co4HkW71z4/image_thumb%25255B5%25255D.png?imgmax=800" width="716" height="520" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;En los siguientes posts veremos el resto de pantallas del proceso de delivery.&lt;/p&gt;

&lt;p&gt;Saludos 
  &lt;br /&gt;Angel Núñez Salazar&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/802125770402017592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/802125770402017592'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2012/05/single-page-applications-parte-3.html' title='Single Page Applications – Parte 3 – UI Patterns, KnockoutJS'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/-ym6C9wd4KLs/UAfIc8GW7hI/AAAAAAAAAZI/Io6afoZoDPw/s72-c/FolderStructure_thumb%25255B3%25255D.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-6349918807675856808</id><published>2012-04-30T01:02:00.001-07:00</published><updated>2012-08-12T21:24:54.148-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET Web API'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>Single Page Applications – Parte 2 – Server Technologies (ASP.NET MVC y ASP.NET Web API)</title><content type='html'>&lt;p align="justify"&gt;Durante estos posts nos enfocaremos principalmente en el Lado del Cliente (HTML y Javascript) pero de todas maneras necesitamos un Lado del Servidor para trabajar.&lt;/p&gt;  &lt;p align="justify"&gt;Este post lo dedicaremos a implementar el lado del servidor, para esto utilizaremos ASP.NET MVC 4 y ASP.NET Web API, aunque podría ser cualquier otra tecnología de nuestro agrado.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;strong&gt;Nota:&lt;/strong&gt; ASP.NET MVC 4 y ASP.NET Web API actualmente se encuentran en Beta y pueden ser descargados de &lt;a href="http://www.asp.net/mvc/mvc4" target="_blank"&gt;aquí&lt;/a&gt;. &lt;/p&gt;  &lt;p align="justify"&gt;Al aplicar estas tecnologías, el lado del servidor quedaría de la siguiente manera:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-J7dH1Dq39Cc/UAeag_KGgpI/AAAAAAAAAXY/uarvuf1a8lU/s1600-h/dataservices%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="dataservices" border="0" alt="dataservices" src="http://lh4.ggpht.com/-E1BnKhW-0zQ/UAeahX_3OZI/AAAAAAAAAXg/VwbsfU6OZTw/dataservices_thumb%25255B2%25255D.png?imgmax=800" width="162" height="267" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h4&gt;ASP.NET MVC 4&lt;/h4&gt;  &lt;p&gt;Utilizaremos esta tecnología para organizar y crear los recursos HTML, Javascript y CSS que luego serán servidos por parte del servidor.&lt;/p&gt;  &lt;p&gt;Lo primero que haremos será crear un proyecto ASP.NET MVC 4 en blanco.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-T0BR4bvHK2w/UAeamA_EuVI/AAAAAAAAAXo/1DUtnP1s9Lg/s1600-h/newproject%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="newproject" border="0" alt="newproject" src="http://lh4.ggpht.com/-GBRESKoW8oI/UAeaqkuOaCI/AAAAAAAAAXw/FcbZ7j3op58/newproject_thumb%25255B2%25255D.png?imgmax=800" width="616" height="413" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-wzkJVyhD6UE/UAeasY8ainI/AAAAAAAAAX4/sbY9CzvOgN0/s1600-h/selecttemplate%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="selecttemplate" border="0" alt="selecttemplate" src="http://lh6.ggpht.com/-NHObKk-bs3o/UAeauhzEBsI/AAAAAAAAAYA/SV121hwSPLs/selecttemplate_thumb%25255B2%25255D.png?imgmax=800" width="494" height="454" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-YDGDpFCvzlI/UAeawF1oRsI/AAAAAAAAAYI/xlOAzpEhkN8/s1600-h/solutionexplorer%25255B5%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="solutionexplorer" border="0" alt="solutionexplorer" src="http://lh6.ggpht.com/-UrU-2WWG-ig/UAeayYTxruI/AAAAAAAAAYQ/pv14RnLqp8A/solutionexplorer_thumb%25255B3%25255D.png?imgmax=800" width="209" height="275" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Agregamos la hoja de estilos y modificamos el &lt;em&gt;_Layout.cshtml&lt;/em&gt; según el Bakery Template de WebMatrix. &lt;/p&gt;  &lt;p&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;&amp;lt;!&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;DOCTYPE&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;html&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;           &lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;html&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;           &lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;head&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;meta&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;charset&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;/&amp;gt;&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;meta&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;name&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;viewport&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;content&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;width=device-width&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;/&amp;gt;&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;title&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;Fourth Coffee -&lt;span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;@&lt;/font&gt;&lt;/span&gt;ViewBag.Title&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;title&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;link&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;href&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00" color="#000000"&gt;@&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;System&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;Web&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;Optimization&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;BundleTable&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;Bundles&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;ResolveBundleUrl&lt;/span&gt;&lt;span style="color: "&gt;(&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;)&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;rel&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;/&amp;gt;&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;link&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;href&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00" color="#000000"&gt;@&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;System&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;Web&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;Optimization&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;BundleTable&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;Bundles&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;ResolveBundleUrl&lt;/span&gt;&lt;span style="color: "&gt;(&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Content/themes/base/css&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;)&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;rel&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;stylesheet&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;type&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;text/css&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;/&amp;gt;&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;src&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;&lt;/span&gt;&lt;/font&gt;&lt;span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00" color="#000000"&gt;@&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;System&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;Web&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;Optimization&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;BundleTable&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;Bundles&lt;/span&gt;&lt;span style="color: "&gt;.&lt;/span&gt;&lt;span style="color: "&gt;ResolveBundleUrl&lt;/span&gt;&lt;span style="color: "&gt;(&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;~/Scripts/js&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;)&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;script&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;           &lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;head&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;           &lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;body&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;page&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;header&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;p&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;site-title&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;a&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;href&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;Fourth Coffee&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;a&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;p&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;ul&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;menu&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;li&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;a&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;href&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;Home&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;a&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;li&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;li&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;a&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;href&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;~/About&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000"&gt;About Us&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;a&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;li&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;ul&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;body&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;         &lt;br /&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00"&gt;@&lt;/font&gt;&lt;/span&gt;RenderBody()           &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;id&lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;=&lt;/span&gt;&lt;span style="color: "&gt;&amp;quot;footer&amp;quot;&lt;/span&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;&lt;/font&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;&amp;amp;copy;&lt;/font&gt;&lt;/span&gt;&lt;span style="background-image: none; background-attachment: scroll; background-repeat: repeat; background-position: 0% 0%"&gt;&lt;font style="background-color: #ffff00" color="#000000"&gt;@&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DateTime&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Now.Year - Fourth Coffee          &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;         &lt;br /&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;div&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;           &lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;body&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#0000ff"&gt;&lt;span style="color: "&gt;&amp;gt;&lt;/span&gt;           &lt;br /&gt;&lt;span style="color: "&gt;&amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#800000"&gt;html&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 12pt" color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Creamos la clase &lt;em&gt;HomeController&lt;/em&gt; que retorne la única vista de nuestra aplicación. &lt;/p&gt;  &lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;HomeController&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Controller&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;{&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ActionResult&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; Index()&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; View();&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;

&lt;h4&gt;ASP.NET Web API&lt;/h4&gt;
Nos permite crear y exponer de manera muy simple servicios bajo el &lt;strong&gt;protocolo HTTP&lt;/strong&gt; siguiendo un estilo de arquitectura &lt;strong&gt;REST&lt;/strong&gt;. Algunos de sus beneficios son: 

&lt;br /&gt;

&lt;ul&gt;
  &lt;li&gt;Crear servicios REST. &lt;/li&gt;

  &lt;li&gt;Consultas ODATA. &lt;/li&gt;

  &lt;li&gt;Diferentes tipos de formatos: JSON, XML, etc. &lt;/li&gt;

  &lt;li&gt;Soporte de varios elementos ya existentes dentro ASP.NET: Model Binding, Routing, Validation, Filters, etc. &lt;/li&gt;

  &lt;li&gt;Soporte de inyección de dependencias. &lt;/li&gt;

  &lt;li&gt;Fácilmente testeable de manera unitaria. &lt;/li&gt;
&lt;/ul&gt;

&lt;p align="justify"&gt;Mediante ASP.NET Web API implementaremos nuestro &lt;strong&gt;Data Services&lt;/strong&gt; endpoint para exponer servicios que envíen y reciban datos en formato JSON desde el cliente. Para esto realizaremos lo siguiente: &lt;/p&gt;

&lt;p align="justify"&gt;Creamos las clases del modelo para la aplicación y crearemos un DbContext típico de Entity Framework. &lt;/p&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;AppDbContext&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DbContext&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;{&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; AppDbContext() : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;base&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;bakery&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;) { }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IDbSet&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Product&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;gt; Products { &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;get&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;set&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;; }&lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;Utilizando Nuget agregamos la referencia a &lt;strong&gt;AspNetWebApi.Data&lt;/strong&gt;, luego creamos un controller que herede de &lt;strong&gt;AspNetWebApi.Data.DbDataController&lt;/strong&gt;, los controllers dentro de Web API funcionan de manera muy similar a MVC y permiten exponer servicios HTTP. &lt;/p&gt;

&lt;p align="justify"&gt;También creamos un servicio que devuelva todos los productos en formato JSON. &lt;/p&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ProductsController&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DbDataController&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;AppDbContext&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;gt;&lt;br /&gt;{&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;#160;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IQueryable&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Product&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;&amp;gt; Get()&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; DbContext.Products.AsQueryable();&lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Nota:&lt;/strong&gt; Retornar los datos como IQueryable y no como IEnumerable permite que se puedan realizar consultas ODATA. &lt;/p&gt;

&lt;p&gt;Probamos nuestro servicio levantando toda la aplicación y accediendo a la siguiente URL: &lt;a href="http://[domain]/api/products"&gt;http://[domain]/api/products&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh4.ggpht.com/-AxlGjMTpWbg/T5-M3DjYv0I/AAAAAAAAATI/GZ94e_3wCrY/s1600-h/image%25255B16%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/-owNKy8FFVjU/T5-M6GDTyFI/AAAAAAAAATQ/maTWt_58_5o/image_thumb%25255B9%25255D.png?imgmax=800" width="683" height="356" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Esta URL corresponde a nuestro servicio HTTP, debido a que existe la siguiente ruta registrada dentro del Global.asax.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh3.ggpht.com/-WIGzLK3GP-g/UAea1DJzqYI/AAAAAAAAAYY/sAHRUnY2Rpg/s1600-h/webapiroute%25255B4%25255D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="webapiroute" border="0" alt="webapiroute" src="http://lh5.ggpht.com/-bTw_6uW8b5c/UAea2o7f3UI/AAAAAAAAAYg/VPSTkCxgnGo/webapiroute_thumb%25255B2%25255D.png?imgmax=800" width="612" height="254" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p align="justify"&gt;Asimismo, nuestro servicio HTTP dentro del controller tiene el nombre de “Get”, entonces por convención será mapeado automáticamente a todos los &lt;strong&gt;GET Request&lt;/strong&gt;.&lt;/p&gt;

&lt;p align="justify"&gt;Por otro lado el servicio HTTP ha retornado XML, esto se debe a que Chrome envía por defecto en la cabecera de la solicitud &lt;strong&gt;Accept: application/xml&lt;/strong&gt;; si en la cabecera se envía &lt;strong&gt;Accept: application/json&lt;/strong&gt;, el servicio retornaría automáticamente los datos en formato JSON.&lt;/p&gt;

&lt;p&gt;Por el momento esto es todo lo que necesitamos implementar en el lado del servidor.&lt;/p&gt;

&lt;h4&gt;Recursos Adicionales&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://www.asp.net/mvc/mvc4"&gt;http://www.asp.net/mvc/mvc4&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2012/02/23/asp-net-web-api-part-1.aspx"&gt;http://weblogs.asp.net/scottgu/archive/2012/02/23/asp-net-web-api-part-1.aspx&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://sebys.com.ar/2012/04/23/rest-con-asp-net-web-api/"&gt;http://sebys.com.ar/2012/04/23/rest-con-asp-net-web-api/&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;
Hasta el siguiente post. 

&lt;br /&gt;Saludos. 


  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/6349918807675856808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/6349918807675856808'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2012/04/single-page-applications-parte-2.html' title='Single Page Applications – Parte 2 – Server Technologies (ASP.NET MVC y ASP.NET Web API)'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/-E1BnKhW-0zQ/UAeahX_3OZI/AAAAAAAAAXg/VwbsfU6OZTw/s72-c/dataservices_thumb%25255B2%25255D.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-2236615905419399187</id><published>2012-04-29T19:28:00.001-07:00</published><updated>2012-08-12T21:26:53.081-07:00</updated><title type='text'>Single Page Applications – Parte 1 – Definición y Arquitectura</title><content type='html'>&lt;p&gt;En esta serie de posts veremos los conceptos detrás de las SPAs y como implementar una de estas aplicaciones.&lt;/p&gt;  &lt;h4&gt;¿Qué son las Single Page Applications?&lt;/h4&gt;  &lt;p align="justify"&gt;SPAs son aplicaciones o sitios web que se ejecutan persistentemente sobre la misma página sin necesidad de recargar sin importar como el usuario interactúe.&lt;/p&gt;  &lt;p align="justify"&gt;Son aplicaciones ricas y responsivas que combinan lo mejor de la web y el escritorio, implementadas con Javascript y HTML5.&lt;/p&gt;  &lt;h4&gt;¿Qué beneficios tienen?&lt;/h4&gt;  &lt;p&gt;Por qué deberíamos considerar este tipo de aplicaciones:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Buena experiencia de usuario. &lt;/li&gt;    &lt;li&gt;Reducen la carga en el servidor. &lt;/li&gt;    &lt;li&gt;Similares a las aplicaciones nativas. &lt;/li&gt;    &lt;li&gt;Pueden trabajar offline. &lt;/li&gt;    &lt;li&gt;Pueden desplegarse en App-Stores &lt;/li&gt; &lt;/ul&gt;  &lt;h4&gt;¿Cuál es su arquitectura?&lt;/h4&gt;  &lt;p&gt;Una &lt;strong&gt;aplicación “multi-page” tradicional&lt;/strong&gt; usualmente sigue una arquitectura similar a la siguiente:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-rmxnypXrbwk/T534w6FefrI/AAAAAAAAARM/C_hV4ZIxqqU/s1600-h/image38.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-3V75fsyj1IU/T534yg5MK1I/AAAAAAAAARU/oNyBOibMXZM/image_thumb26.png?imgmax=800" width="395" height="269" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Web UI:&lt;/strong&gt; Contiene la lógica de negocio y a su vez se encarga de servir recursos HTML, JS, CSS desde el servidor. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Visible UI:&lt;/strong&gt; Renderiza en el navegador la página web. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; Código Javascript para manipular el comportamiento de la página dentro del navegador. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;En cambio una &lt;strong&gt;aplicación SPA&lt;/strong&gt; tiene una arquitectura similar a la siguiente:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-bXtYgW2v8Lw/T53407cviaI/AAAAAAAAARc/wYNV4KQIZdA/s1600-h/image32.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-SE7PhJkTRVs/T5344AgWAKI/AAAAAAAAARk/1bmQ0_hh6dQ/image_thumb22.png?imgmax=800" width="403" height="359" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;&lt;strong&gt;Web UI:&lt;/strong&gt; Contiene la lógica de negocio y a su vez se encarga de servir recursos HTML, JS, CSS desde el servidor. &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;strong&gt;Data Services:&lt;/strong&gt; Provee datos en formato JSON o XML desde el servidor. &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;strong&gt;Data Access Layer:&lt;/strong&gt; Se encarga de solicitar datos al servidor para que estos sean mostrados, enviar datos para que sean procesados. &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;strong&gt;Application Layer:&lt;/strong&gt; También contiene mucha otra lógica relacionada a Navegación, Binding, etc. &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;&lt;strong&gt;Visible UI:&lt;/strong&gt; También hace uso de templates para renderizar los datos.&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h4&gt;¿Cómo implementar una SPA?&lt;/h4&gt;  &lt;p align="justify"&gt;En los posts sucesivos veremos detalladamente como implementar una de estas aplicaciones. Como ejemplo utilizaremos el &lt;strong&gt;“Bakery Template”&lt;/strong&gt; que es uno de los templates para construir aplicaciones web que viene por defecto dentro de &lt;strong&gt;WebMatrix&lt;/strong&gt;.&lt;/p&gt;  &lt;p align="justify"&gt;Reutilizaremos su layout y estilos pero reharemos por completo toda la funcionalidad para que funcione como un SPA.&lt;/p&gt;  &lt;p align="justify"&gt;&lt;img style="display: inline" src="http://answers.oreilly.com/uploads/monthly_08_2011/post-2018-13135075354.png" /&gt;&lt;/p&gt;  &lt;p&gt;Hasta el siguiente post.    &lt;br /&gt;Saludos.&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/2236615905419399187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/2236615905419399187'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2012/04/single-page-applications-parte-1.html' title='Single Page Applications – Parte 1 – Definición y Arquitectura'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/-3V75fsyj1IU/T534yg5MK1I/AAAAAAAAARU/oNyBOibMXZM/s72-c/image_thumb26.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-4837657976721894248</id><published>2011-11-08T12:23:00.001-08:00</published><updated>2012-07-18T22:31:32.860-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Refactoring'/><category scheme='http://www.blogger.com/atom/ns#' term='Presentación'/><category scheme='http://www.blogger.com/atom/ns#' term='Agile'/><title type='text'>Refactoring Golf</title><content type='html'>&lt;p&gt;Los días 11, 12 y 13 de Octubre se realizó en Buenos Aires (Argentina) la conferencia &lt;a href="http://agiles2011.agiles.org/" target="_blank"&gt;Agiles2011&lt;/a&gt;, es el evento latinoamericano más grande sobre metodologías ágiles, al cual tuve el placer de asistir y dar una ponencia junto con &lt;a href="http://twitter.com/#!/quiroz_gustavo" target="_blank"&gt;Gustavo Quiroz&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;La ponencia se titula “Refactoring Golf”, es un workshop avanzado de Refactoring que está inspirado en la ponencia original realizada en el Software Craftmaship 2010.&lt;/p&gt;  &lt;h4&gt;Materiales&lt;/h4&gt;  &lt;p&gt;Les dejo todos los materiales del workshop, están decentemente reutilizables. Pueden utilizarlos libremente, solo déjenme sus comentarios e ideas para poder mejorar el material. Pueden hacer un fork al repositorio para agregarle más cosas pero no se olviden de avisarme para que yo también pueda usarlas =).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://agiles2011.agiles.org/programa/sesion/22/" target="_blank"&gt;Descripción y Reglas.&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="https://github.com/snahider/Refactoring-Golf" target="_blank"&gt;Repositorio Github&lt;/a&gt;: Contiene código fuente, diapositivas y documentos para imprimir.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sc2010subs.wordpress.com/2010/08/13/refactoring-golf-dave-cleal-ivan-moore/" target="_blank"&gt;Ponencia Original.&lt;/a&gt;&lt;/p&gt;  &lt;h4&gt;Diapositivas&lt;/h4&gt;  &lt;p&gt;Adicionalmente he subido la presentación a Slideshare para que puedan comentarla y compartirla.&lt;/p&gt;  &lt;div style="width: 425px" id="__ss_10067961"&gt;&lt;iframe height="355" marginheight="0" src="http://www.slideshare.net/slideshow/embed_code/10067961?rel=0" frameborder="0" width="425" marginwidth="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/div&gt;  &lt;h4&gt;Retrospectiva&lt;/h4&gt;  &lt;p&gt;Esta es una imagen con la retrospectiva realizada al final del workshop.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-0H2SNinvP_M/UAebmMnWleI/AAAAAAAAAYo/jx1cfMX6oM4/s1600-h/retrospectiva%25255B4%25255D.jpg"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="retrospectiva" border="0" alt="retrospectiva" src="http://lh3.ggpht.com/-OBpI9aJmuIw/UAebsHUjd4I/AAAAAAAAAYw/RnGT5ghGaOw/retrospectiva_thumb%25255B2%25255D.jpg?imgmax=800" width="598" height="800" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Saludos    &lt;br /&gt;Angel Núñez Salazar&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/4837657976721894248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/4837657976721894248'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2011/11/refactoring-golf.html' title='Refactoring Golf'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/-OBpI9aJmuIw/UAebsHUjd4I/AAAAAAAAAYw/RnGT5ghGaOw/s72-c/retrospectiva_thumb%25255B2%25255D.jpg?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-2470424727049116244</id><published>2011-10-25T03:26:00.001-07:00</published><updated>2012-08-10T07:02:47.496-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Refactoring'/><title type='text'>Refactoring to Design Patterns</title><content type='html'>&lt;p&gt;En este screencast vamos a ver cómo podemos refactorizar una clase para implementar el patrón State. El código pertenece al caso “Gumball Machine” que se encuentra en el libro &lt;a href="http://www.amazon.com/First-Design-Patterns-Elisabeth-Freeman/dp/0596007124" target="_blank"&gt;Head First Design Patterns&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;El código inicial y final que veremos en el screencast lo podemos descargar de &lt;a href="https://github.com/snahider/Head-First-Design-Patterns"&gt;https://github.com/snahider/Head-First-Design-Patterns&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;iframe height="324" src="http://player.vimeo.com/video/31058355?title=0&amp;amp;byline=0&amp;amp;portrait=0" frameborder="0" width="546" webkitallowfullscreen="webkitallowfullscreen" allowfullscreen="allowfullscreen"&gt;&lt;/iframe&gt;    &lt;br /&gt;&lt;strong&gt;&lt;em&gt;Te recomiendo verlo en &lt;a href="http://vimeo.com/31058355" target="_blank"&gt;HD&lt;/a&gt;.&lt;/em&gt;&lt;/strong&gt;    &lt;br /&gt;Un agradecimiento especial a Israel Antezana (@israelantezana) que me dio esta idea y con el cuál tuve una pequeña sesión de pair programming durante &lt;a href="http://agiles2011.agiles.org/" target="_blank"&gt;Agiles2011&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Update     &lt;br /&gt;&lt;/strong&gt;&lt;a href="http://blogs.jetbrains.com/dotnet/2012/07/resharper-70-is-released/" target="_blank"&gt;Resharper 7&lt;/a&gt; ya viene con el refactoring &lt;em&gt;&lt;strong&gt;Extract Class&lt;/strong&gt;&lt;/em&gt; que nos permite mover miembros de una clase a otra que aún no existe.&lt;/p&gt;  &lt;p&gt;Saludos    &lt;br /&gt;Angel Núñez Salazar&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/2470424727049116244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/2470424727049116244'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2011/10/refactoring-gumball-machine.html' title='Refactoring to Design Patterns'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-8220230438584242940</id><published>2011-03-27T21:28:00.001-07:00</published><updated>2011-03-27T21:29:34.395-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='StructureMap'/><category scheme='http://www.blogger.com/atom/ns#' term='IOC'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Entity Framework'/><title type='text'>Entity Framework 4.1 y ASP.NET MVC 3</title><content type='html'>&lt;p align="justify"&gt;Con la salida de EF 4.1 ha vuelto la discusión sobre el manejo de la &lt;a href="http://martinfowler.com/eaaCatalog/unitOfWork.html" target="_blank"&gt;Unit of Work&lt;/a&gt; en una aplicación web. En este caso vamos a ver algunos pasos utilizando EF 4.1, MVC 3 y StructureMap.&lt;/p&gt;  &lt;h4&gt;Paso 1: El Dominio&lt;/h4&gt;  &lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 12pt"&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;abstract&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Entity&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;    {&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; Id { &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;get&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;set&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;; }&lt;br /&gt;    }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 12pt"&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Post&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;:&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Entity&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;    {&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;String&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; Title { &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;get&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;set&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;; }&lt;br /&gt;&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;String&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; Body { &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;get&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;set&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;; }&lt;br /&gt;&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;List&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Comment&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;gt; Comments { &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;get&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;set&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;; }&lt;br /&gt;&lt;br /&gt;    }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 12pt"&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Comment&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;:&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Entity&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;    {&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; Content { &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;get&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;set&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;; }&lt;br /&gt;&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; PostId { &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;get&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;set&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;; }&lt;br /&gt;&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Post&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; Post { &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;get&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;set&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;; } &lt;br /&gt;    }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;h4&gt;Paso 2: DbContext y la cadena de conexión&lt;/h4&gt;

&lt;p align="justify"&gt;Creamos una clase que extienda de &lt;em&gt;DbContext&lt;/em&gt; para que a través de ella interactuemos con la base de datos. Por defecto busca una cadena de conexión que tenga el mismo nombre de la clase que lo implementa, en este caso una cadena con el nombre de &lt;em&gt;DatabaseContext&lt;/em&gt;. Podemos cambiar el nombre de esta cadena si ingresamos un nuevo parámetro al constructor del &lt;em&gt;DbContext&lt;/em&gt;. &lt;/p&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 12pt"&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DatabaseContext&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DbContext&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;    {&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; DatabaseContext() : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;base&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;Blog&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;) {}&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;&lt;br /&gt;&lt;br /&gt;    }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;    &amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;add&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;name&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;Blog&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;connectionString&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;xXx&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#ff0000"&gt;providerName&lt;/font&gt;&lt;/span&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;System.Data.SqlClient&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font style="font-size: 12pt" color="#0000ff"&gt; /&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;br /&gt;&lt;/pre&gt;

&lt;h4&gt;Paso 3: Los Repositorios&lt;/h4&gt;

&lt;p align="justify"&gt;No me gusta la idea de tener todos los &lt;em&gt;DbSet&lt;/em&gt; dentro del &lt;em&gt;DatabaseContext&lt;/em&gt;, es por esto que creamos un repositorio base que instancie un &lt;em&gt;DbSet&lt;/em&gt; para su correspondiente entidad y también agregamos algunos métodos comunes.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 12pt"&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Repository&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;T&amp;gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;where&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; T : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Entity&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;    {&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; Repository()&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; database = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ObjectFactory&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.GetInstance&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DatabaseContext&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;gt;();&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Set = database.Set&amp;lt;T&amp;gt;();&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;protected&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;readonly&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DbSet&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;lt;T&amp;gt; Set;&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IEnumerable&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;lt;T&amp;gt; All()&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Set.ToList();&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;void&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; Add(T entity)&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Set.Add(entity);&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; T Get(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; id)&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Set.SingleOrDefault(x=&amp;gt;x.Id==id);&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;void&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; Delete(T entity)&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.Set.Remove(entity);&lt;br /&gt;        }&lt;br /&gt;    }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;En este caso no estamos inyectando el &lt;em&gt;DatabaseContext&lt;/em&gt; por el constructor sino lo obtenemos a través de un &lt;em&gt;Service Locator&lt;/em&gt;, esto con la finalidad de no tener que escribir el constructor en todos los repositorios hijos.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 12pt"&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;interface&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IPostRepository&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;    {&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Post&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; Get(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; id);&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;void&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; Add(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Post&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; post);&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;void&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; Delete(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Post&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; post);&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IEnumerable&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Post&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;gt; All();&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IEnumerable&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Comment&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;gt; Comments(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; idPost);&lt;br /&gt;    }&lt;br /&gt; &lt;br /&gt;    &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;PostRepository&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Repository&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Post&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;gt;, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IPostRepository&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;    {&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IEnumerable&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Comment&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;gt; Comments(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;int&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; idPost)&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.Set.SelectMany(p =&amp;gt; p.Comments)&lt;br /&gt;                        .Where(c =&amp;gt; c.Post.Id == idPost).ToList();&lt;br /&gt;        }&lt;br /&gt;    }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;h4&gt;Paso 4: Inyección de Dependencias&lt;/h4&gt;

&lt;p align="justify"&gt;En ASP.NET MVC 3 se ha formalizado la inyección de dependencias, es por esto que podemos implementar la nueva interfaz &lt;a href="http://bradwilson.typepad.com/blog/2010/10/service-location-pt5-idependencyresolver.html" target="_blank"&gt;&lt;em&gt;IDependencyResolver&lt;/em&gt;&lt;/a&gt; e indicarle a MVC que utilice esta clase para determinar cuál es la instancia correcta cuando se solicite un determinado tipo.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 12pt"&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;StructureMapDependencyResolver&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;:&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IDependencyResolver&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;    {&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; StructureMapDependencyResolver(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IContainer&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; container)&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.container = container;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;private&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;readonly&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IContainer&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; container;&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;object&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; GetService(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Type&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; serviceType)&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; (serviceType.IsAbstract || serviceType.IsInterface)&lt;br /&gt;            {&lt;br /&gt;                &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.container.TryGetInstance(serviceType);&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;br /&gt;            }&lt;br /&gt; &lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.container.GetInstance(serviceType);&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IEnumerable&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;object&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;gt; GetServices(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Type&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; serviceType)&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; container.GetAllInstances&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;object&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;gt;()&lt;br /&gt;                .Where(s =&amp;gt; s.GetType() == serviceType);&lt;br /&gt;        }&lt;br /&gt;    }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;Ahora configuramos &lt;em&gt;StructureMap&lt;/em&gt; y registramos la clase anterior dentro del &lt;em&gt;Global.asax&lt;/em&gt;. El punto más importante en cuanto al manejo de la unidad de trabajo es configurar el contenedor para que se tenga una única instancia del &lt;em&gt;DatabaseContext&lt;/em&gt; a nivel de todo un request.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 12pt"&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;protected&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;void&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; Application_Start()&lt;br /&gt;    {&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ObjectFactory&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Initialize(x =&amp;gt;&lt;br /&gt;        {&lt;br /&gt;            x.For&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DatabaseContext&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;gt;().HybridHttpOrThreadLocalScoped();&lt;br /&gt;            x.For&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IPostRepository&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;gt;().Use&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;PostRepository&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;gt;();&lt;br /&gt;        });&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DependencyResolver&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.SetResolver(&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;StructureMapDependencyResolver&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ObjectFactory&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Container));&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;AreaRegistration&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.RegisterAllAreas();&lt;br /&gt;        RegisterGlobalFilters(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;GlobalFilters&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;.Filters);&lt;br /&gt;        RegisterRoutes(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;RouteTable&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.Routes);&lt;br /&gt;    }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;Si utilizamos &lt;em&gt;StructureMap&lt;/em&gt; necesitamos limpiar todos los objetos que tienen un ciclo de vida a nivel de request, en este caso el &lt;em&gt;DatabaseContext&lt;/em&gt;.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 12pt"&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;protected&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;void&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; Application_EndRequest(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;object&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; sender, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;EventArgs&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; e)&lt;br /&gt;    {&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ObjectFactory&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.ReleaseAndDisposeAllHttpScopedObjects();&lt;br /&gt;    }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;h4&gt;Paso 4: El Filtro de Transacción&lt;/h4&gt;

&lt;p align="justify"&gt;Ahora que se comparte el mismo DatabaseContext en todo un request, cuando este finalice, necesitamos enviar a la base de datos todos los cambios que se hayan realizado como si fueran una sola unidad o transacción. Para esto creamos un filtro de acción que guarde los cambios realizados dentro del DatabaseContext.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 12pt"&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;TransactionAttribute&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ActionFilterAttribute&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;    {&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DatabaseContext&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; Context { &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;get&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;set&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;; }&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;override&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;void&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; OnActionExecuted(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ActionExecutedContext&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; filterContext)&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;if&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; (filterContext.Exception == &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;null&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;)&lt;br /&gt;            {&lt;br /&gt;                &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;try&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;                {&lt;br /&gt;                    Context.SaveChanges();&lt;br /&gt;                }&lt;br /&gt;                &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;catch&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; (&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DbUpdateConcurrencyException&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;)&lt;br /&gt;                {&lt;br /&gt;                    &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#008000"&gt;//manejar errores de concurrencia como sea conveniente&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;                }&lt;br /&gt;                &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;catch&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; (&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Exception&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;)&lt;br /&gt;                {&lt;br /&gt;                    &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#008000"&gt;//manejar errores genéricos como sea conveniente&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;font color="#000000"&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;Para poder inyectar la instancia correcta del &lt;em&gt;DatabaseContext&lt;/em&gt; dentro del filtro, necesitamos extender la clase &lt;em&gt;FilterAttributeFilterProvider&lt;/em&gt;.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 12pt"&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;StructureMapFilterProvider&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;FilterAttributeFilterProvider&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;    {&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;private&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;readonly&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IContainer&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; container;&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; StructureMapFilterProvider(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IContainer&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; container)&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.container = container;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;override&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IEnumerable&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Filter&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;gt; GetFilters&lt;br /&gt;        (&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ControllerContext&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; controllerContext, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ActionDescriptor&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; actionDescriptor)&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; filters = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;base&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.GetFilters(controllerContext, actionDescriptor);&lt;br /&gt; &lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;foreach&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; (&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; filter &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;in&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt; filters)&lt;br /&gt;            {&lt;br /&gt;                container.BuildUp(filter.Instance);&lt;br /&gt;            }&lt;br /&gt; &lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; filters;&lt;br /&gt;        }&lt;br /&gt;    }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;Modificamos el &lt;em&gt;Global.asax&lt;/em&gt; para registrar la clase anterior e indicarle a &lt;em&gt;StructureMap&lt;/em&gt; que realice inyección a través de propiedades para el &lt;em&gt;DatabaseContext&lt;/em&gt;.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 12pt"&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;protected&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;void&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; Application_Start()&lt;br /&gt;    {&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ObjectFactory&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Initialize(x =&amp;gt;&lt;br /&gt;        {&lt;br /&gt;            x.For&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DatabaseContext&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;gt;().HybridHttpOrThreadLocalScoped();&lt;br /&gt;            x.For&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IPostRepository&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;gt;().Use&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;PostRepository&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;gt;();&lt;br /&gt;            x.SetAllProperties(p =&amp;gt; p.OfType&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DatabaseContext&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;gt;());&lt;br /&gt;        });&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DependencyResolver&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.SetResolver(&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;StructureMapDependencyResolver&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ObjectFactory&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Container));&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;FilterProviders&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Providers.Add(&lt;br /&gt;                &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;StructureMapFilterProvider&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ObjectFactory&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.Container));&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;AreaRegistration&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.RegisterAllAreas();&lt;br /&gt;        RegisterGlobalFilters(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;GlobalFilters&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;.Filters);&lt;br /&gt;        RegisterRoutes(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;RouteTable&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;.Routes);&lt;br /&gt;    }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;h4&gt;Paso 5: Registrando las entidades en el DatabaseContext&lt;/h4&gt;

&lt;p&gt;Debido a que los &lt;em&gt;DbSets&lt;/em&gt; de nuestras entidades no se encuentran dentro del &lt;em&gt;DatabaseContext&lt;/em&gt;, este no las reconoce para poder utilizarlas; para registrarlas debemos sobrescribir el método &lt;em&gt;OnModelCreating&lt;/em&gt; y por cada entidad llamar al método genérico &lt;em&gt;modelbuilder.Entity&amp;lt;T&amp;gt;.&lt;/em&gt;&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 12pt"&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DatabaseContext&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DbContext&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;    {&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; DatabaseContext() : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;base&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;Blog&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;){}&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;protected&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;override&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;void&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; OnModelCreating(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DbModelBuilder&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; modelBuilder)&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; method = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;typeof&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;DbModelBuilder&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;).GetMethod(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;Entity&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;);&lt;br /&gt; &lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; types = &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Assembly&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.GetExecutingAssembly().GetExportedTypes()&lt;br /&gt;                .Where(t =&amp;gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;typeof&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Entity&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;).IsAssignableFrom(t) &amp;amp;&amp;amp; &lt;br /&gt;                            !t.IsAbstract &amp;amp;&amp;amp; !t.IsInterface)&lt;br /&gt;                .ToList();&lt;br /&gt; &lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;foreach&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; (&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; type &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;in&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; types)&lt;br /&gt;            {&lt;br /&gt;                &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;var&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; genericMethod = method.MakeGenericMethod(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;new&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;[] { type });&lt;br /&gt;                genericMethod.Invoke(modelBuilder, &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;null&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;);&lt;br /&gt;            } &lt;br /&gt;        }&lt;br /&gt;    }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;h4&gt;Paso 6: Utilizando lo anterior en los Controllers &lt;/h4&gt;

&lt;p&gt;Creamos un controller y algunas acciones que utilicen los repositorios y el filtro anteriormente creado.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size: 12pt"&gt;    &lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;class&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;PostsController&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; : &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Controller&lt;/font&gt;&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;    {&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;private&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;readonly&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IPostRepository&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; postRepository;&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; PostsController(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IPostRepository&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; postRepository)&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;this&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;.postRepository = postRepository;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ActionResult&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; Index()&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;IEnumerable&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;lt;&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Post&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;&amp;gt; posts = postRepository.All();&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; View(posts);&lt;br /&gt;            &lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ActionResult&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; Create()&lt;br /&gt;        {&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; View();&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        [&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;HttpPost&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;]&lt;br /&gt;        [&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Transaction&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;]&lt;br /&gt;        &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;public&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;ActionResult&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; Create(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#2b91af"&gt;Post&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt; post)&lt;br /&gt;        {&lt;br /&gt;            postRepository.Add(post);&lt;br /&gt;            &lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#0000ff"&gt;return&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt; RedirectToAction(&lt;/font&gt;&lt;span style="color: "&gt;&lt;font color="#a31515"&gt;&amp;quot;index&amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#000000"&gt;);&lt;br /&gt;        }&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#000000"&gt;&lt;br /&gt;    }&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;h4&gt;Último Paso: Creando la Base de datos&lt;/h4&gt;

&lt;p align="justify"&gt;Por último podemos crear la base de datos y sus tablas de forma manual o dejar que estas se creen automáticamente cuando se instancie por primera vez el DatabaseContext.&lt;/p&gt;

&lt;p align="justify"&gt;Con esto ya tenemos todo lo necesario para el manejo de la unidad de trabajo a nivel de request. 
  &lt;br /&gt;Hasta el siguiente post.&lt;/p&gt;

&lt;p&gt;Saludos 
  &lt;br /&gt;Angel Núñez Salazar&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/8220230438584242940'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/8220230438584242940'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2011/03/entity-framework-4-y-aspnet-mvc-3.html' title='Entity Framework 4.1 y ASP.NET MVC 3'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-4341998761407295019</id><published>2011-01-09T14:39:00.001-08:00</published><updated>2011-01-09T14:46:27.360-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sonar'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='XP'/><category scheme='http://www.blogger.com/atom/ns#' term='Teamcity'/><category scheme='http://www.blogger.com/atom/ns#' term='ContinuousIntegration'/><category scheme='http://www.blogger.com/atom/ns#' term='MsBuild'/><title type='text'>Integración Continua – Resultado Final</title><content type='html'>&lt;p&gt;En este post veremos cuál es el resultado final al que llegaríamos si realizamos toda la configuración de nuestro proceso de integración continua.&lt;/p&gt; &lt;object width="546" height="324"&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=18597418&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=0&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1&amp;amp;autoplay=0&amp;amp;loop=0" /&gt;&lt;embed src="http://vimeo.com/moogaloop.swf?clip_id=18597418&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=0&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1&amp;amp;autoplay=0&amp;amp;loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="546" height="324"&gt;&lt;/embed&gt;&lt;/object&gt;  &lt;br /&gt;Te recomiendo verlo activando la &lt;a href="http://vimeo.com/18597418" target="_blank"&gt;calidad HD&lt;/a&gt;   &lt;p&gt;En la &lt;a href="http://snahider.blogspot.com/2011/01/integracion-continua-series.html" target="_blank"&gt;serie de posts sobre integración continua&lt;/a&gt; hablaremos con más detalle de todo lo visto en el video. No se lo pierdan.&lt;/p&gt;  &lt;p&gt;Saludos.    &lt;br /&gt;Angel Núñez Salazar&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/4341998761407295019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/4341998761407295019'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2011/01/integracion-continua-resultado-final.html' title='Integración Continua – Resultado Final'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-6064893472180726238</id><published>2011-01-09T13:03:00.001-08:00</published><updated>2011-01-09T14:51:26.351-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sonar'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Teamcity'/><category scheme='http://www.blogger.com/atom/ns#' term='ContinuousIntegration'/><category scheme='http://www.blogger.com/atom/ns#' term='MsBuild'/><title type='text'>Integración Continua Series</title><content type='html'>&lt;p&gt;Acá tenemos la lista de posts de la serie de Integración Continua.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Parte 1.- &lt;a href="http://snahider.blogspot.com/2010/12/integracion-continua-parte-1.html" target="_blank"&gt;Introducción, Roles y Transformaciones XML&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Parte 2.- &lt;a href="http://snahider.blogspot.com/2010/12/integracion-continua-parte-2.html" target="_blank"&gt;Compilación y Transformaciones XML&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://snahider.blogspot.com/2011/01/integracion-continua-resultado-final.html" target="_blank"&gt;Resultado Final&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Saludos    &lt;br /&gt;Angel Núñez Salazar&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/6064893472180726238'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/6064893472180726238'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2011/01/integracion-continua-series.html' title='Integración Continua Series'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-2928534438335790927</id><published>2010-12-21T23:35:00.001-08:00</published><updated>2010-12-22T00:01:09.212-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='XP'/><category scheme='http://www.blogger.com/atom/ns#' term='ContinuousIntegration'/><category scheme='http://www.blogger.com/atom/ns#' term='MsBuild'/><title type='text'>Integración Continua – Parte 2</title><content type='html'>&lt;p align="justify"&gt;&lt;a href="http://snahider.blogspot.com/2010/12/integracion-continua-parte-1.html" target="_blank"&gt;Anteriormente&lt;/a&gt; vimos como podemos utilizar las transformaciones XML para manejar diferentes configuraciones en nuestras aplicaciones. Pero existe un problema con estas transformaciones: solo se realizan cuando publicamos o creamos un paquete de despliegue.&lt;/p&gt;  &lt;p align="justify"&gt;Esto impide los siguientes escenarios:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Aprovechar las configuraciones al momento de probar nuestra aplicación desde el mismo VS utilizando F5. &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Utilizas las configuraciones desde diferentes proyectos para realizar pruebas de integración en diferentes ambientes utilizando alguna herramienta de testing. &lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p align="justify"&gt;Por suerte existe la capacidad de poder utilizar las transformaciones de manera independiente a una publicación, esto es posible gracias al task “TransformXML” de MsBuild.&lt;/p&gt;  &lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;span&gt;&lt;font color="#a31515"&gt;TransformXml&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;Source&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;{Source File}&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;#160;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;Transform&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;{Transform File}&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;#160;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;Destination&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;{Destination File}&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size: 12pt" color="#0000ff"&gt; /&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p align="justify"&gt;El inconveniente con este task es que el “source file” y el “destination file” no pueden ser el mismo archivo Web.config. Esta dificultad la podemos solucionar si organizamos nuestros archivos de una manera diferente.&lt;/p&gt;

&lt;p align="justify"&gt;Para esto copiamos el archivo Web.config y a este nuevo archivo le cambiamos de nombre a Web.Template.config.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Je6WwZtSU6Q/TRGqAgobkvI/AAAAAAAAAMY/-iZ2c1FimJw/s1600-h/image%5B19%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_Je6WwZtSU6Q/TRGqCgISCMI/AAAAAAAAAMc/nFMze2gH7IA/image_thumb%5B9%5D.png?imgmax=800" width="292" height="114" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Editamos nuestro archivo de proyecto.&lt;a href="http://lh3.ggpht.com/_Je6WwZtSU6Q/TRGqDWtUF6I/AAAAAAAAAMg/FDhDPEu7u2o/s1600-h/image%5B7%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_Je6WwZtSU6Q/TRGqEKgH81I/AAAAAAAAAMk/dfBfzGUS4uU/image_thumb%5B3%5D.png?imgmax=800" width="397" height="93" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Y modificamos la sección donde se encuentran nuestros archivos config a lo siguiente.&lt;/p&gt;

&lt;p&gt;&lt;font face="Consolas"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;&amp;#160; &amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;span&gt;&lt;font color="#a31515"&gt;ItemGroup&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;None&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;Include&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;Web.Template.config&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt; /&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;Content&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;Include&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;Web.config&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;DependentUpon&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;Web.Template.config&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#a31515"&gt;DependentUpon&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;Content&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;None&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;Include&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;Web.Development.config&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;DependentUpon&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;Web.Template.config&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#a31515"&gt;DependentUpon&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;None&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;None&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;Include&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;Web.ContinuousIntegration.config&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;DependentUpon&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;Web.Template.config&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#a31515"&gt;DependentUpon&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;None&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;None&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;Include&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;Web.Production.config&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;DependentUpon&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;Web.Template.config&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#a31515"&gt;DependentUpon&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;None&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;ItemGroup&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size: 12pt" color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p align="justify"&gt;De esta manera le indicamos al VS que agrupe todos nuestros archivos config dentro del Web.Template.config. Asimismo utilizamos el nodo Content únicamente en el Web.config para que todos los demás archivos se borren al momento de realizar una publicación.&lt;/p&gt;

&lt;p align="justify"&gt;Para lograr que la transformación se realice siempre e inmediatamente después de la compilación, descomentamos el target “AfterBuild” e incluimos dentro el task “TransformXML”.&lt;/p&gt;

&lt;p&gt;&lt;font face="Consolas"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;&amp;#160; &amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;span&gt;&lt;font color="#a31515"&gt;Target&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;Name&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;AfterBuild&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;TransformXml&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;Source&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;Web.Template.config&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;#160;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;Transform&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;Web.$(Configuration).config&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;#160;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;Destination&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;Web.config&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt; /&amp;gt;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;Target&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size: 12pt" color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color="#0000ff" size="3" face="Consolas"&gt;&lt;span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;Con esto el VS siempre que compile realizará una transformación utilizando el Web,Template.config como origen, utilizará el archivo de transformación correspondiente de acuerdo a nuestra configuración y dará como resultado un archivo Web.config.&lt;/p&gt;

&lt;p&gt;Ahora que nuestra transformación se ejecuta al momento de compilar tenemos que evitarla al momento de publicar.&lt;/p&gt;

&lt;pre style="line-height: normal; font-family: "&gt;&lt;font face="Consolas"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;&amp;#160; &amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;span&gt;&lt;font color="#a31515"&gt;PropertyGroup&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font style="font-size: 12pt"&gt;&lt;font face="Consolas"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;TransformWebConfigEnabled&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;False&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#a31515"&gt;TransformWebConfigEnabled&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;#160; &amp;lt;/&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#a31515"&gt;PropertyGroup&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size: 12pt" color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;Para finalizar y poder utilizar el task “TransformXml” lo importamos desde la instalación del VS.&lt;/p&gt;

&lt;p&gt;&lt;font face="Consolas"&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&lt;font style="font-size: 12pt"&gt;&amp;#160; &amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;font style="font-size: 12pt"&gt;&lt;span&gt;&lt;font color="#a31515"&gt;UsingTask&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;&amp;#160;&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;TaskName&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;TransformXml&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Consolas"&gt;&lt;font style="font-size: 12pt"&gt;&lt;font color="#0000ff"&gt;&lt;span&gt;&amp;#160;&lt;/span&gt; 

        &lt;br /&gt;&lt;span&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/font&gt;&lt;span&gt;&lt;font color="#ff0000"&gt;AssemblyFile&lt;/font&gt;&lt;/span&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;=&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;span&gt;&lt;font color="#0000ff"&gt;$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;span&gt;&lt;font style="font-size: 12pt" color="#0000ff"&gt; /&amp;gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;Grabamos y cargamos nuevamente nuestro proyecto.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Je6WwZtSU6Q/TRGqEuegsFI/AAAAAAAAAMo/wb-mVE1ugH0/s1600-h/image%5B25%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_Je6WwZtSU6Q/TRGqFutAhGI/AAAAAAAAAMs/fbaAbTW98Sg/image_thumb%5B17%5D.png?imgmax=800" width="302" height="103" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Para probar la transformación simplemente cambiamos de configuración.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Je6WwZtSU6Q/TRGqGEbBKOI/AAAAAAAAAMw/WgdOGVXvlOY/s1600-h/image%5B29%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_Je6WwZtSU6Q/TRGqG1QztRI/AAAAAAAAAM0/oG02KYWtpjQ/image_thumb%5B19%5D.png?imgmax=800" width="270" height="44" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Compilamos y al finalizar veremos que el contenido del Web.config ha sido el resultado de una transformación.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Je6WwZtSU6Q/TRGqHyA6jXI/AAAAAAAAAM4/cJXP-3nXqec/s1600-h/image%5B34%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_Je6WwZtSU6Q/TRGqIk-PjgI/AAAAAAAAAM8/dQl2BYe0PPQ/image_thumb%5B22%5D.png?imgmax=800" width="612" height="105" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Resumen&lt;/h4&gt;

&lt;p&gt;Las transformaciones facilitan el manejo de múltiples configuraciones, pero existen algunos escenarios en los cuales necesitamos que estas no solo se realicen al momento de publicar. Utilizando los pasos anteriores podemos aprovechar las transformaciones también al momento de compilar y sin afectar la publicación.&lt;/p&gt;

&lt;h4&gt;Lo que se viene&lt;/h4&gt;

&lt;p&gt;En los siguientes post veremos como aprovechar estas transformaciones para realizar tareas más complejas utilizando MsBuild.&lt;/p&gt;

&lt;p&gt;Saludos 
  &lt;br /&gt;Angel Núñez Salazar&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/2928534438335790927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/2928534438335790927'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2010/12/integracion-continua-parte-2.html' title='Integración Continua – Parte 2'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_Je6WwZtSU6Q/TRGqCgISCMI/AAAAAAAAAMc/nFMze2gH7IA/s72-c/image_thumb%5B9%5D.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-8360659585017480886</id><published>2010-12-21T16:53:00.001-08:00</published><updated>2010-12-21T23:46:42.054-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='XP'/><category scheme='http://www.blogger.com/atom/ns#' term='ContinuousIntegration'/><title type='text'>Integración Continua - Parte 1</title><content type='html'>&lt;h4&gt;El Problema&lt;/h4&gt;  &lt;p&gt;La mayoría de los proyectos de software tienen un retraso oculto desde el momento que el equipo dice “terminado” hasta que el software está realmente listo a ser potencialmente puesto en producción.&lt;/p&gt;  &lt;p&gt;Una de las causas principales es que la integración del trabajo de todo el equipo se realiza al final de la iteración o inclusive del proyecto, esto ocasiona toda clase de problemas: falta de visibilidad del estado real (valor y calidad), errores en etapas finales el proyecto y excesivo tiempo al integrar el trabajo.&lt;/p&gt;  &lt;h4&gt;Integración Continua&lt;/h4&gt;  &lt;p&gt;La “Integración Continua” surge como una práctica en el desarrollo e software que pretende solucionar estos problemas.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;“Continuous Integration is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily - leading to multiple integrations per day. Each integration is verified by an automated build to detect integration errors as quickly as possible.”&amp;#160; - Martin Fowler.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="justify"&gt;En su forma más simple esta práctica no requiere de herramientas complejas ni nada parecido, nada más se necesita constancia para integrar y verificar que se cumplen los estándares que el equipo establece. &lt;/p&gt;  &lt;p align="justify"&gt;La herramientas existen para simplificar y automatizar las tareas que son difíciles de realizar y que nos consumen mucho tiempo, siéntanse libres de utilizar las herramientas que más prefieran, por mi parte aprovechare esta serie de posts para mostrarles las que a mi me gustan.&lt;/p&gt;  &lt;p align="justify"&gt;Para esto reutilizaremos las fuentes de nuestro proyecto ASP.NET MVC “ThunderJob” que ya hemos estado avanzando anteriormente. Comenzemos!&lt;/p&gt;  &lt;h4&gt;Web.config Transformations&lt;/h4&gt;  &lt;p align="justify"&gt;VS2010 trae una nueva característica que nos permite modificar nuestros archivos web.config (en general cualquier XML) de manera automática y con configuraciones diferentes para los ambientes de nuestra aplicación (desarrollo, test, producción, etc)&lt;/p&gt;  &lt;p align="justify"&gt;Lo que tenemos que hacer es crear los diferentes roles de configuración que va a tener nuestra aplicación, esto lo hacemos mediante el Configuration Manager:&lt;/p&gt;  &lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_Je6WwZtSU6Q/TRFLR8kTWEI/AAAAAAAAALM/3Ju2rboURCs/s1600-h/image%5B62%5D.png"&gt;&lt;img style="border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_Je6WwZtSU6Q/TRFLbCPJksI/AAAAAAAAALQ/CzHfCed7msY/image_thumb%5B41%5D.png?imgmax=800" width="272" height="89" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p align="justify"&gt;Por defecto tenemos 2 roles: Debug y Release, pero podemos agregar o eliminar los que queramos. Para nuestro ejemplo vamos a modificar los roles de nuestra aplicación MVC de la siguiente manera:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Je6WwZtSU6Q/TRFLd_uU-cI/AAAAAAAAALU/aSGItIoE5Ow/s1600-h/image%5B46%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_Je6WwZtSU6Q/TRFLnL9n4YI/AAAAAAAAALY/wM1SLcpF0Iw/image_thumb%5B25%5D.png?imgmax=800" width="560" height="364" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Ahora lo que tenemos que hacer es producir un nuevo Web.config por cada configuración diferente. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Je6WwZtSU6Q/TRFLpNHep7I/AAAAAAAAALc/yd4R3BwYyIk/s1600-h/image%5B61%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_Je6WwZtSU6Q/TRFLtwkSSQI/AAAAAAAAALg/yXqTy1BPTE8/image_thumb%5B40%5D.png?imgmax=800" width="361" height="187" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Y nos dará como resultado&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Je6WwZtSU6Q/TRFLu3_Vs3I/AAAAAAAAALk/2EUnxFENNsg/s1600-h/image%5B69%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_Je6WwZtSU6Q/TRFLw9bjdkI/AAAAAAAAALo/4Wu2pTJn6V4/image_thumb%5B44%5D.png?imgmax=800" width="265" height="89" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Si abrimos uno de los archivos generados (Web.Development.config) veremos que solo tiene un pequeño contenido y no todo el Web.config original.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Je6WwZtSU6Q/TRFLyChrgEI/AAAAAAAAALs/ZqDLe__d8tE/s1600-h/image%5B82%5D.png"&gt;&lt;img style="display: block; float: none; margin-left: auto; margin-right: auto" title="image" alt="image" src="http://lh3.ggpht.com/_Je6WwZtSU6Q/TRFL1ZRwVsI/AAAAAAAAALw/CQ5b6v6gvSQ/image_thumb%5B53%5D.png?imgmax=800" width="657" height="85" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Esto se debe a que las transformaciones del Web.config funcionan sobre un motor de transformaciones XML, el cuál toma el archivo original (Web.config), un archivo de transformación (Web.Development.config) y aplica la reglas que se encuentran en este último para generar un Web.config final.&lt;/p&gt;  &lt;p&gt;Existen múltiples tipos transformaciones que podemos utilizar, en este artículo &lt;a href="http://blogs.msdn.com/b/webdevtools/archive/2009/05/04/web-deployment-web-config-transformation.aspx"&gt;Web Deployment: Web.Config Transformation&lt;/a&gt; podremos encontrar información más detallada sobre estas.&lt;/p&gt;  &lt;p&gt;Para probar nuestras transformaciones vamos a publicar nuestra aplicación. Para esto primero seleccionamos la configuración que queremos utilizar.&lt;a href="http://lh5.ggpht.com/_Je6WwZtSU6Q/TRFL14C0DWI/AAAAAAAAAL0/ETkQtFG52sE/s1600-h/image%5B94%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_Je6WwZtSU6Q/TRFL2sDYrFI/AAAAAAAAAL4/1C7l7xnSYTM/image_thumb%5B59%5D.png?imgmax=800" width="244" height="25" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Y desde el VS publicaremos la aplicación a un directorio local.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Je6WwZtSU6Q/TRFL5axJz8I/AAAAAAAAAL8/__66zPfz464/s1600-h/image%5B86%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_Je6WwZtSU6Q/TRFL7JCWqQI/AAAAAAAAAMA/hnmrEES25EI/image_thumb%5B55%5D.png?imgmax=800" width="434" height="160" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Je6WwZtSU6Q/TRFL__B2djI/AAAAAAAAAME/EDtQm5MvYu4/s1600-h/image%5B91%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_Je6WwZtSU6Q/TRFMDKwmkOI/AAAAAAAAAMI/UCPRpbjjgWI/image_thumb%5B58%5D.png?imgmax=800" width="336" height="320" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Al dirigirnos al directorio destino y ver el contenido del archivo Web.config, nos daremos cuenta que el contenido de este ha sido modificado según la transformación correspondiente a nuestra configuración (Web.Development.config).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Je6WwZtSU6Q/TRFMEWSaAFI/AAAAAAAAAMM/ebzWHfMkDJA/s1600-h/image%5B98%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_Je6WwZtSU6Q/TRFMFopQv_I/AAAAAAAAAMQ/6F7kPxslkRc/image_thumb%5B61%5D.png?imgmax=800" width="584" height="118" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h4&gt;Resumen&lt;/h4&gt;  &lt;p&gt;Las nuevas transformaciones XML del VS2010 nos permite un mejor manejo de roles con diferentes propiedades para cada uno de los ambientes donde se vaya a desplegar nuestra aplicación.&lt;/p&gt;  &lt;h4&gt;Lo que se viene&lt;/h4&gt;  &lt;p&gt;A continuación veremos cuales son algunas de las limitaciones que tienen estas transformaciones y como podemos superarlas.&lt;/p&gt;  &lt;p&gt;No se pierdan esta nueva serie de posts, saludos.    &lt;br /&gt;Angel Núñez Salazar&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/8360659585017480886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/8360659585017480886'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2010/12/integracion-continua-parte-1.html' title='Integración Continua - Parte 1'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_Je6WwZtSU6Q/TRFLbCPJksI/AAAAAAAAALQ/CzHfCed7msY/s72-c/image_thumb%5B41%5D.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-1976862242180328695</id><published>2010-12-05T15:29:00.001-08:00</published><updated>2010-12-05T15:29:08.582-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>Taller de ASP.NET MVC</title><content type='html'>&lt;p&gt;Tengo el agrado de contarles la apertura del taller de ASP.NET MVC, donde podrán aprender el uso y la aplicación de esta gran tecnología.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.flickr.com/photos/8252899@N04/5217881139" target="_blank"&gt;&lt;img style="margin: " src="http://farm6.static.flickr.com/5250/5217881139_37f06c0152_z.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Debido a varias sugerencias hemos decidido mover el inicio al &lt;font size="3"&gt;&lt;strong&gt;8 de enero &lt;/strong&gt;&lt;/font&gt;ya que diciembre es un poco difícil para algunos y así nadie pueda perderse el taller.&lt;/p&gt;  &lt;p&gt;El precio final se establecerá de acuerdo al número total de inscritos, así que inviten a sus amigos y compañeros de trabajo.&lt;/p&gt;  &lt;p&gt;Pueden registrar su interés aquí: &lt;a href="https://spreadsheets.google.com/viewform?formkey=dDV5X3UzeUhaX29TSmpkcFFWWUdQN0E6MQ" target="_blank"&gt;&lt;font size="4"&gt;&lt;strong&gt;Taller ASP.NET MVC&lt;/strong&gt;&lt;/font&gt;&lt;/a&gt;     &lt;br /&gt;No se pierdan esta gran oportunidad.&lt;/p&gt;  &lt;p&gt;Saludos    &lt;br /&gt;Angel Núñez Salazar&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/1976862242180328695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/1976862242180328695'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2010/12/taller-de-aspnet-mvc.html' title='Taller de ASP.NET MVC'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://farm6.static.flickr.com/5250/5217881139_37f06c0152_t.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-1809051363707911248</id><published>2010-12-04T16:08:00.000-08:00</published><updated>2010-12-05T16:32:34.281-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='IOC'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='NHibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring.NET'/><title type='text'>Presentación Spring.NET</title><content type='html'>&lt;p&gt;Este 27 de noviembre se realizó el &lt;a href="http://www.flickr.com/photos/8252899@N04/5217784691" target="_blank"&gt;Spring Community Day 2010&lt;/a&gt; en el cuál estuve dando una presentación sobre Spring.NET.&lt;/p&gt; &lt;object id="__sse5975526" width="425" height="355"&gt;&lt;param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=spring-net-101129214244-phpapp01&amp;amp;stripped_title=springnet-5975526&amp;amp;userName=snahider" /&gt;&lt;param name="allowFullScreen" value="true" /&gt;&lt;param name="allowScriptAccess" value="always" /&gt;&lt;embed name="__sse5975526" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=spring-net-101129214244-phpapp01&amp;amp;stripped_title=springnet-5975526&amp;amp;userName=snahider" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;  &lt;p&gt;El código de la presentación lo podemos descargar desde GoogleCode con nuestro cliente de subversion favorito.    &lt;br /&gt;&lt;a title="https://springperu.googlecode.com/svn/trunk/scd2010/spring-net" href="https://springperu.googlecode.com/svn/trunk/scd2010/spring-net"&gt;https://springperu.googlecode.com/svn/trunk/scd2010/spring-net&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;El evento fue totalmente orientado a gente Javera así que fue una presentación difícil de dar. &lt;/p&gt;  &lt;p&gt;La presentación fue puramente código(desarrollo casi desde cero de una aplicación web con ASP.NET MVC y Spring). Esto resultó muy beneficioso para los que tenían experiencia en esta framework y así se dieran una idea de su uso en el mundo NET, pero creo que también fue muy complicada para los recién iniciados.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Je6WwZtSU6Q/TPwseRopBnI/AAAAAAAAALA/_uUoN_JzzT0/s1600-h/spring.net%5B14%5D.jpg"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="spring.net" border="0" alt="spring.net" src="http://lh3.ggpht.com/_Je6WwZtSU6Q/TPwsfavV7pI/AAAAAAAAALE/WXNbyDBpqPI/spring.net_thumb%5B10%5D.jpg?imgmax=800" width="524" height="267" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Saludos    &lt;br /&gt;Angel Núñez Salazar&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/1809051363707911248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/1809051363707911248'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2010/12/presentacion-springnet.html' title='Presentación Spring.NET'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_Je6WwZtSU6Q/TPwsfavV7pI/AAAAAAAAALE/WXNbyDBpqPI/s72-c/spring.net_thumb%5B10%5D.jpg?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-9090380522068507981</id><published>2010-10-17T23:45:00.001-07:00</published><updated>2010-10-17T23:57:20.998-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='UnitTesting'/><category scheme='http://www.blogger.com/atom/ns#' term='Refactoring'/><title type='text'>¿Realmente sabes Refactorizar?</title><content type='html'>&lt;p&gt;Primero definamos algunos conceptos:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Smell:&lt;/strong&gt; Indicador de que algo podría estar mal en nuestro código ( mal diseño, responsabilidades incorrectas, etc).       &lt;br /&gt;&lt;em&gt;&lt;strong&gt;El lugar donde no queremos estar.&lt;/strong&gt;&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Refactoring: &lt;/strong&gt;Cambios a la estructura interna del software con la finalidad de mejorarla y sin que se haya visto afectado su comportamiento.&lt;em&gt;        &lt;br /&gt;&lt;strong&gt;El camino hacia…&lt;/strong&gt;&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Pattern:&lt;/strong&gt; Solución reutilizable a un problema que se presenta de manera común en el diseño de software.&lt;strong&gt;        &lt;br /&gt;&lt;em&gt;El lugar donde queremos estar.&lt;/em&gt;&lt;/strong&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Para cada uno de estos existen catálogos con listas innumerables, pero lo que no encontramos fácilmente es como aplicarlos correctamente. En este post nos vamos a enfocar en &lt;strong&gt;Refactoring&lt;/strong&gt; y en algunas estrategias para su aplicación.&lt;/p&gt;  &lt;p&gt;Las dos estrategias que veremos son: &lt;em&gt;&lt;strong&gt;Paralell Change&lt;/strong&gt;&lt;/em&gt; y &lt;em&gt;&lt;strong&gt;Narrowed Change&lt;/strong&gt;&lt;/em&gt;. Entonces, para que gastar más líneas si podemos verlo en el siguiente video:&lt;/p&gt;  &lt;p&gt;&lt;iframe height="324" src="http://player.vimeo.com/video/15941247?byline=0&amp;amp;portrait=0" frameborder="0" width="546"&gt;&lt;/iframe&gt;    &lt;br /&gt;Te recomiendo verlo en &lt;a href="http://vimeo.com/15941247" target="_blank"&gt;HD&lt;/a&gt; para una mejor calidad.&lt;/p&gt;  &lt;p&gt;Para comprender cuál es la finalidad de todo esto les recomiendo ver &lt;a href="http://www.infoq.com/presentations/The-Limited-Red-Society"&gt;“The Limited Red Society”&lt;/a&gt; del gran &lt;a href="http://agiles2010.agiles.org/lang/es/2010/04/keynote-speaker-joshua-kerievsky/"&gt;Joshua Kerievsky&lt;/a&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;No se olviden de practicar sus refactorings y hasta el siguiente Post.    &lt;br /&gt;Saludos&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/9090380522068507981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/9090380522068507981'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2010/10/realmente-sabes-refactorizar.html' title='¿Realmente sabes Refactorizar?'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-6211459090640215431</id><published>2010-09-08T09:42:00.001-07:00</published><updated>2010-09-08T09:42:01.663-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XP'/><category scheme='http://www.blogger.com/atom/ns#' term='Scrum'/><category scheme='http://www.blogger.com/atom/ns#' term='Agile'/><title type='text'>Ágiles 2010: 3ras Jornadas Latinoamericanas sobre Metodologías Ágiles</title><content type='html'>&lt;p&gt;Ágiles 2010 es una excelente oportunidad para encontrase con profesionales de IT de la región, interesados en compartir sus experiencias, debatir y capacitarse en temas relacionados con el desarrollo de software a través del uso de metodologías ágiles.&lt;/p&gt;  &lt;p&gt;Esta tercera edición, con sede en la ciudad de Lima, Perú, contará con la presencia de especialistas locales e internacionales, quienes compartirán su conocimiento durante los cuatro días que durará el evento.&lt;/p&gt;  &lt;p&gt;El programa incluye distintos tipos de actividades: presentaciones, sesiones interactivas, talleres y espacios abiertos de debate.&lt;/p&gt;  &lt;p&gt;Entre los invitados internacionales se encuentran los keynote speakers Lee Devin y Joshua Kerievsky, que también estarán brindando cursos durante el evento.&lt;/p&gt;  &lt;div style="text-align: center"&gt;&lt;a href="http://agiles2010.agiles.org"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Agiles 2010" border="0" alt="Agiles 2010" src="http://agiles2010.agiles.org/wp-content/uploads/2010/04/banner-es.gif" /&gt;&lt;/a&gt; &lt;/div&gt;  &lt;p&gt;&lt;b&gt;¡&lt;a href="http://agiles2010.agiles.org/lang/es/inscripcion/"&gt;Inscríbete&lt;/a&gt; y se parte de Ágiles 2010! &lt;/b&gt;&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/6211459090640215431'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/6211459090640215431'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2010/09/agiles-2010-3ras-jornadas.html' title='Ágiles 2010: 3ras Jornadas Latinoamericanas sobre Metodologías Ágiles'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-8644404089020810489</id><published>2010-05-04T06:33:00.001-07:00</published><updated>2010-05-12T23:50:11.417-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='NHibernate'/><title type='text'>ASP.NET MVC y otras Yerbas – Parte 7</title><content type='html'>&lt;h4&gt;Como Configurar NHibernate “From Zero to Hero”&lt;/h4&gt;  &lt;p align="justify"&gt;Seguramente lo que más confunde cuando alguien va a empezar con NHibernate es la gran cantidad de formas, colores y sabores que existen para integrarlo en la infraestructura y arquitectura de nuestra aplicación. A continuación solo una de ellas:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:57e1505e-8f7e-48c1-8aed-5d12ae02c520" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;object width="546" height="328"&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=11454299&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=0&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" /&gt;&lt;embed src="http://vimeo.com/moogaloop.swf?clip_id=11454299&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=0&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="546" height="328"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;/div&gt; También pueden verlo en &lt;a href="http://www.vimeo.com/11454299" target="_blank"&gt;HD&lt;/a&gt;.   &lt;p&gt;No se olviden de ver el resto de la serie &lt;a href="http://snahider.blogspot.com/2010/03/aspnet-mvc-series.html" target="_blank"&gt;ASP.NET MVC y otras Yerbas&lt;/a&gt;.     &lt;br /&gt;Hasta el siguiente post.     &lt;br /&gt;Saludos&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/8644404089020810489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/8644404089020810489'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2010/05/aspnet-mvc-y-otras-yerbas-parte-7.html' title='ASP.NET MVC y otras Yerbas – Parte 7'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-1287528563498984124</id><published>2010-03-26T22:22:00.001-07:00</published><updated>2010-05-12T23:48:09.337-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>ASP.NET MVC Series</title><content type='html'>&lt;p&gt;Acá tenemos la lista de posts de la serie ASP.NET MVC y otras Yerbas&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Parte 1.- &lt;a href="http://snahider.blogspot.com/2009/10/aspnet-mvc-y-otras-yerbas-1.html" target="_blank"&gt;DDD (Domain Driven Design)&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Parte 2.- &lt;a href="http://snahider.blogspot.com/2009/11/aspnet-mvc-y-otras-yerbas-parte-2.html" target="_blank"&gt;Unit Testing and TDD (Test Driven Development)&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Parte 3.- &lt;a href="http://snahider.blogspot.com/2009/11/aspnet-mvc-y-otras-yerbas-parte-3.html" target="_blank"&gt;TDD: Kata Prime Factors&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Parte 4.- &lt;a href="http://snahider.blogspot.com/2009/12/aspnet-mvc-y-otras-yerbas-parte-4.html" target="_blank"&gt;Domain Services and Repositories&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Parte 5.- &lt;a href="http://snahider.blogspot.com/2010/03/aspnet-mvc-y-otras-yerbas-parte-5.html" target="_blank"&gt;Controllers and ViewModels&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Parte 6.- &lt;a href="http://snahider.blogspot.com/2010/03/aspnet-mvc-y-otras-yerbas-parte-6.html" target="_blank"&gt;Bootstrap MVC with IOC (Inversion of Control)&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Parte 7.- &lt;a href="http://snahider.blogspot.com/2010/05/aspnet-mvc-y-otras-yerbas-parte-7.html" target="_blank"&gt;Configure NHibernate&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Saludos.&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/1287528563498984124'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/1287528563498984124'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2010/03/aspnet-mvc-series.html' title='ASP.NET MVC Series'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-5121461238882511260</id><published>2010-03-26T20:58:00.001-07:00</published><updated>2010-03-26T22:38:58.396-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='IOC'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><title type='text'>ASP.NET MVC y otras Yerbas – Parte 6</title><content type='html'>&lt;p&gt;Es hora de hablar sobre “&lt;strong&gt;Inversion of Control&lt;/strong&gt;”:&lt;/p&gt;  &lt;h4&gt;El Problema&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Je6WwZtSU6Q/S618J4HzdrI/AAAAAAAAAFM/yGmTtzXz6Xg/s1600-h/image35.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_Je6WwZtSU6Q/S62AEIttUjI/AAAAAAAAAFQ/1Y7FMlmKsyg/image_thumb21.png?imgmax=800" width="573" height="327" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="justify"&gt;Qué observamos en el código anterior:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;La clase SmtpClient está directamente referenciada por la clase HomeController y está última controla su creación, lo que tiene como consecuencia un fuerte acoplamiento entre estas dos clases. &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;La clase HomeController es consciente de la clase SmtClient y su funcionamiento, por lo tanto si alguna vez tenemos que realizar algún cambio sobre el envió de correo: como enviarlo por una cola de mensajes o incluso cambiar por una nueva librería, la clase HomeController se verá afectada. &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Se dificulta la realización de pruebas sobre la clase HomeController. &lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;h4&gt;La Solución&lt;/h4&gt;  &lt;p align="justify"&gt;Si somos capaces de cambiar el control de la creación de la clase SmtpClient a una tercera entidad, podremos ver resuelto nuestro problema. Y esa solución es: Inversion of Control. &lt;/p&gt;  &lt;h4&gt;Inversion of Control&lt;/h4&gt;  &lt;blockquote&gt;   &lt;p align="center"&gt;“Is an abstract principle describing an aspect of some software architecture designs in which the flow of control of a system is inverted in comparison to traditional architecture of software”      &lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/Inversion_of_control" target="_blank"&gt;Wikipedia&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p align="justify"&gt;Podemos implementar este patrón de 2 maneras distintas:&lt;/p&gt;  &lt;h4&gt;Dependency Inyeccion&lt;/h4&gt;  &lt;p&gt;La idea es tener un objeto en el “mundo exterior” que se encargue de proveer o inyectar la implementación adecuada (EmailSender) a la clase listener (HomeController)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Je6WwZtSU6Q/S62AE-aoneI/AAAAAAAAAFU/e5ei_YkHpRE/s1600-h/image29.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_Je6WwZtSU6Q/S62AGFXfEpI/AAAAAAAAAFY/OaegS_aO4XA/image_thumb17.png?imgmax=800" width="510" height="255" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Je6WwZtSU6Q/S62AKTwbIvI/AAAAAAAAAFc/919V5ZvNyJE/s1600-h/image13.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_Je6WwZtSU6Q/S62AK482IwI/AAAAAAAAAFg/yVNNbGy5O3k/image_thumb7.png?imgmax=800" width="508" height="84" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h4&gt;Service Locator&lt;/h4&gt;  &lt;p&gt;La idea es tener una entidad “dentro de la clase” que conozca cómo obtener la implementación adecuada que esta clase podría necesitar.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Je6WwZtSU6Q/S62AND2winI/AAAAAAAAAFk/2jTKfPQ8gkI/s1600-h/image33.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_Je6WwZtSU6Q/S62BLLtPESI/AAAAAAAAAFs/efHu8JJ318E/image_thumb19.png?imgmax=800" width="511" height="235" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Ahora veamos cómo estas cosas se utilizan en nuestra aplicación de ejemplo y adicionalmente veremos como podemos configurarla para que levante y ejecute.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:672c6784-b2ee-44ad-837f-f2b3e9a17cf6" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;object width="546" height="328"&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=10471981&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=0&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" /&gt;&lt;embed src="http://vimeo.com/moogaloop.swf?clip_id=10471981&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=0&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="546" height="328"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;/div&gt; También podemos verlo en &lt;a href="http://www.vimeo.com/10471981" target="_blank"&gt;HD&lt;/a&gt;   &lt;p&gt;&lt;/p&gt;  &lt;p&gt;No se olviden de ver el resto de la serie &lt;a href="http://snahider.blogspot.com/2010/03/aspnet-mvc-series.html" target="_blank"&gt;ASP.NET MVC y otras Yerbas&lt;/a&gt;.     &lt;br /&gt;Hasta el siguiente post.     &lt;br /&gt;Saludos&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/5121461238882511260'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/5121461238882511260'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2010/03/aspnet-mvc-y-otras-yerbas-parte-6.html' title='ASP.NET MVC y otras Yerbas – Parte 6'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_Je6WwZtSU6Q/S62AEIttUjI/AAAAAAAAAFQ/1Y7FMlmKsyg/s72-c/image_thumb21.png?imgmax=800' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-3511783681840907007</id><published>2010-03-05T12:15:00.001-08:00</published><updated>2010-03-26T22:38:19.574-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='TDD'/><title type='text'>ASP.NET MVC y otras Yerbas – Parte 5</title><content type='html'>&lt;p&gt;Le llego el turno al Controlador y al &lt;strike&gt;Modelo&lt;/strike&gt; ViewModel.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:fb2d00af-099d-476b-aeca-dc0beaaa6640" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;object width="546" height="328"&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=9928798&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=0&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" /&gt;&lt;embed src="http://vimeo.com/moogaloop.swf?clip_id=9928798&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=0&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="546" height="328"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;/div&gt; Para una mejor calidad también podemos verlo en &lt;a href="http://www.vimeo.com/9928798" target="_blank"&gt;HD&lt;/a&gt;.   &lt;p align="justify"&gt;Controlador.- Es el encargado de recibir y manejar las peticiones realizadas por los usuarios, y mostrar la vista adecuada.&lt;/p&gt;  &lt;p align="justify"&gt;ViewModel.- Es aquí donde viene el dilema. Comúnmente existe el problema en decidir cuál es la “M” dentro de nuestro modelo MVC. Es una entidad ?, un DTO ? , algo más ?.&lt;/p&gt;  &lt;p align="justify"&gt;Para algunos la “M” se refiere a una clase que ha sido diseñada para satisfacer las necesidades específicas de una vista en particular - “ViewModel”. Pero cuales son las razones que nos llevan a optar en utilizar una nueva clase únicamente para una vista, ya que esto supone un mayor esfuerzo (aparentemente):&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;A medida que las vistas se vuelven más complicadas es difícil mantener una sincronización entre las clases del dominio y las necesidades de la vista. Imaginemos una vista con un wizard que envía información sobre el paso al cual quiere ir el usuario, definitivamente no vamos a querer agregar esa información a una entidad del dominio ya que es únicamente de interés de la vista. &lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Muchas veces escribimos lógica innecesaria dentro de una vista, esto se puede representar en algo tan simple como: Html.Hidden(&lt;font color="#ff0000"&gt;“id”&lt;/font&gt;,Model!=&lt;font color="#000080"&gt;null&lt;/font&gt;?Model.ID:&lt;font color="#008080"&gt;0&lt;/font&gt;) .Debido a que las vistas son difíciles de probar es recomendable mover esta lógica a otra clase que facilite esta tarea. &lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;Al utilizar las entidades como “Model”, la vista tendrá conocimiento detallado de parte de dominio, lo cual para algunos puede significar que se daña de cierta manera la estructura y la arquitectura de la aplicación. Creo que esto no es más que otra decisión de diseño y esto lo podemos ver en varias aplicaciones antiguas, en especial aquellas que tienen a la base de datos relacional como centro de la aplicación y utilizan a las “entidades” como simples transmisores de datos. Después de vivir tantos años con estas aplicaciones podemos decir que las bases de datos relacionales no lo son todo en esta vida.&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Los siguientes links tienen bastante información de los patrones que podemos utilizar para diseñar un ViewModel y las ventajas y desventajas de estos.&lt;/p&gt;  &lt;p&gt;&lt;a title="http://geekswithblogs.net/michelotti/archive/2009/10/25/asp.net-mvc-view-model-patterns.aspx" href="http://geekswithblogs.net/michelotti/archive/2009/10/25/asp.net-mvc-view-model-patterns.aspx"&gt;http://geekswithblogs.net/michelotti/archive/2009/10/25/asp.net-mvc-view-model-patterns.aspx&lt;/a&gt;     &lt;br /&gt;&lt;a title="http://blogs.msdn.com/simonince/archive/2010/01/26/view-models-in-asp-net-mvc.aspx" href="http://blogs.msdn.com/simonince/archive/2010/01/26/view-models-in-asp-net-mvc.aspx"&gt;http://blogs.msdn.com/simonince/archive/2010/01/26/view-models-in-asp-net-mvc.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;No se olviden de ver el resto de las serie &lt;a href="http://snahider.blogspot.com/2010/03/aspnet-mvc-series.html" target="_blank"&gt;ASP.NET MVC y otras Yerbas&lt;/a&gt;.     &lt;br /&gt;Hasta el siguiente post.     &lt;br /&gt;Saludos.&lt;/p&gt;  </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/3511783681840907007'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/3511783681840907007'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2010/03/aspnet-mvc-y-otras-yerbas-parte-5.html' title='ASP.NET MVC y otras Yerbas – Parte 5'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author></entry><entry><id>tag:blogger.com,1999:blog-876077106867749026.post-3685407457202066809</id><published>2009-12-15T21:47:00.001-08:00</published><updated>2010-03-26T22:37:54.990-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MVC'/><category scheme='http://www.blogger.com/atom/ns#' term='DDD'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='TDD'/><title type='text'>ASP.NET MVC y otras Yerbas – Parte 4</title><content type='html'>&lt;p align="justify"&gt;Sin más que decir volvamos a la acción:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:0f83e47d-5a77-4405-9b50-aba44893f692" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;object width="546" height="328"&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=8133083&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" /&gt;&lt;embed src="http://vimeo.com/moogaloop.swf?clip_id=8133083&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="546" height="328"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;/div&gt; Para una mejor calidad también podemos verlo en &lt;a href="http://www.vimeo.com/8133083" target="_blank"&gt;HD&lt;/a&gt;.   &lt;p&gt;A continuación tenemos una explicación de algunas de las cosas que hemos visto: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div align="justify"&gt;¿Cuál es la estructura de un test? Un Test tiene comúnmente la siguiente estructura:&lt;/div&gt;      &lt;ul&gt;       &lt;li&gt;         &lt;div align="justify"&gt;Arrange: Creamos todas las precondiciones y entradas necesarias.&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;Act: Realizamos la acción en el objeto que estamos probando.&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;Assert: Verificamos que los resultados que esperamos se han producido. &lt;/div&gt;          &lt;br /&gt;&lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;¿Qué es lo primero que hacemos para agregar alguna funcionalidad? Sin duda alguna, lo primero es realizar el Test. &lt;/div&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;¿Cómo nombramos al Test? Tener un estándar para los nombres de los test resulta importante ya que nos brinda un descripción entendible por propios y extraños sobre lo que realiza el test. Recuerden los Test son Documentación. La convención de nombre &lt;strong&gt;Método_Escenario_ComportamientoEsperado&lt;/strong&gt; nos ayuda bastante a lograr lo anteriormente mencionado. &lt;/div&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;¿Qué es lo que probamos primero? De todas las opciones que tenemos, probamos la más simple, pero que cree funcionalidad real o valor.        &lt;br /&gt;        &lt;br /&gt;Se acuerdan del &lt;a href="http://snahider.blogspot.com/2009/11/aspnet-mvc-y-otras-yerbas-parte-3.html" target="_blank"&gt;Kata de Números Primos&lt;/a&gt;, la primera prueba que realizamos fue verificar que el número 1 nos devolvía una lista vacía. No comenzamos probando que el número 9 nos devolviera 2 primos, ni tampoco que un número menor a uno 1 arrojara una excepción.         &lt;br /&gt;        &lt;br /&gt;Pero, ¿porqué comenzamos con la más simple?… Imaginen que hubiéramos comenzado probando cuales son los números primos de 9, la cantidad de código escrito habría sido mucho mayor en relación a una prueba de los números primos de 1 y por lo tanto habría transcurrido mucho más tiempo en completarse el ciclo de TDD ( Red – Green – Refactor) y en obtener el feedback que nos aporta el mismo.         &lt;br /&gt;        &lt;br /&gt;Espérate un momento!, en el video no todas las pruebas han comenzado con la opción más simple….Tomemos como ejemplo un método que suma 2 números (x, y), entonces según lo dicho anteriormente el camino más simple sería crear un test que verifique 0+0=0 y en el código de producción retornamos 0, nuestro siguiente test podría ser que 1+0=1 y en el código de producción retornamos x, por ultimo probar que 2+1=3 y en el código retornamos x+y. (este camino se parece bastante a nuestro Kata verdad). Pero creo que todos sabemos que la implementación a un método de suma es x+y. Entonces en estos casos donde la implementación es un poco obvia, no tenemos que pedir permiso a varios test para poder escribir el código de producción.         &lt;br /&gt;        &lt;br /&gt;Algo parecido sucede en nuestro ejemplo, ya que de alguna manera se tiene una noción de como los servicios y repositorios interactúan juntos; de igual manera, tampoco nos preocupamos de temas más complejos como validaciones ni reglas de negocios. Por lo tanto nos sentimos con cierto nivel de confianza para dar pasos ligeramente más grandes &lt;strong&gt;pero de manera muy rápida&lt;/strong&gt;.         &lt;br /&gt;        &lt;br /&gt;Como sabemos que podemos optar por esto, una pista muy simple la encontramos al escribir el test, si en ese momento nos ponemos a pensar mucho en los detalles (nombre, entradas, salidas) es una señal de que la implementación no es tan simple como parece. Asimismo si nos sentimos seguros de dar pasos más grandes y observamos que los test se rompen muy seguido, quizás debamos hacer pasos más pequeños. &lt;/div&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;¿Qué es lo primero que escribimos en el test? De abajo para arriba, lo primero es el Assert. Esta es una práctica que he encontrado muy útil, ya que al realizar el test, nuestro cerebro&amp;#160; se pone a pensar muchas cosas al mismo tiempo: ¿cómo nombramos los elementos?, ¿cómo lo voy a verificar?, ¿qué me sugieren hacer los otros test?, etc.        &lt;br /&gt;        &lt;br /&gt;Entonces al realizar el Assert primero, aislamos uno de los problemas del resto: ¿cómo lo voy a verificar?, y en base a esto construimos el resto del test:         &lt;br /&gt;        &lt;br /&gt;&lt;/div&gt;      &lt;ul&gt;       &lt;li&gt;         &lt;div align="justify"&gt;¿Cómo lo voy a verificar? Probando que se llame al método Agregar del Repositorio.&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;¿Dónde se llama al método Agregar? Desde el método Registrar de la clase AdministrarEmpresa.&lt;/div&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;¿Qué se requiere para llamar al método Registrar? Pasarle un objeto Empresa.&lt;/div&gt;       &lt;/li&gt;     &lt;/ul&gt;      &lt;p align="justify"&gt;Está práctica junto con la anterior convención de nombres son una combinación muy buena. Asimismo te permite aprovechar bastante las herramientas que te otorga el entorno de desarrollo (&lt;strong&gt;Resharper Rulz!&lt;/strong&gt;). &lt;/p&gt;      &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;     &lt;div align="justify"&gt;Volvamos por un momento al &lt;a href="http://snahider.blogspot.com/2009/11/aspnet-mvc-y-otras-yerbas-parte-3.html" target="_blank"&gt;post anterior&lt;/a&gt;, ahí hemos observado el uso de tests para construir una clase que no depende internamente de ninguna otra.         &lt;br /&gt;&lt;/div&gt;      &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Je6WwZtSU6Q/Syh0Zr3LaKI/AAAAAAAAADU/UZxyxel6puU/s1600-h/image5.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_Je6WwZtSU6Q/Syh0Z5t0eeI/AAAAAAAAADY/fralSOJcVDo/image_thumb3.png?imgmax=800" width="244" height="68" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;      &lt;p align="justify"&gt;Pero en la cruel realidad no todo es tan bonito y simple. Las clases dentro de nuestras aplicaciones tienen dependencias para poder funcionar (bases de datos, web services, etc)&lt;/p&gt;      &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Je6WwZtSU6Q/Syh0aomqmgI/AAAAAAAAADc/JtPynUdcKVA/s1600-h/image11.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_Je6WwZtSU6Q/Syh0bNJESyI/AAAAAAAAADg/fmzYMaXZpQA/image_thumb7.png?imgmax=800" width="358" height="233" /&gt;&lt;/a&gt; &lt;/p&gt;      &lt;p align="justify"&gt;Y esto se pone peor, ya que esas dependencias tienen también sus dependencias, y estas dependencias tienen más dependencias y así sucesivamente. Entonces crear un test puede parecer que se vuelve en una tarea complejísima y posiblemente imposible.        &lt;br /&gt;        &lt;br /&gt;¿Cuál es la solución? &lt;strong&gt;Eliminar esas dependencias&lt;/strong&gt;&lt;em&gt;,&lt;/em&gt; pero sin esas dependencias nuestra clase no va a funcionar, &lt;strong&gt;reemplacemos esas dependencias por algo más simple&lt;/strong&gt;; y como hacemos para que la clase utilice esas nuevas dependencias, &lt;strong&gt;hagamos que el test sea quien controle esas dependencias:&lt;/strong&gt;&lt;/p&gt;      &lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_Je6WwZtSU6Q/Syh0bmbr4PI/AAAAAAAAADk/Pn1LRvCiegE/s1600-h/image28.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_Je6WwZtSU6Q/Syh0cVxtH0I/AAAAAAAAADo/pBLKsWK03e8/image_thumb20.png?imgmax=800" width="323" height="228" /&gt;&lt;/a&gt; &lt;/p&gt;      &lt;p align="justify"&gt;Aquí es donde entran los famosos &lt;strong&gt;Test Doubles&lt;/strong&gt; (&lt;em&gt;“Generic term for any kind of pretend object used in place of a real object for testing purposes” – &lt;a href="http://martinfowler.com/articles/mocksArentStubs.html" target="_blank"&gt;Martin Fowler&lt;/a&gt;&lt;/em&gt; ). &lt;/p&gt;      &lt;p align="justify"&gt;En nuestro ejemplo hemos usado 2 Test Doubles &lt;strong&gt;(Other Simple Class)&lt;/strong&gt;, esto debido a que necesitamos probar nuestras clases &lt;em&gt;RegistrarEmpresa &lt;/em&gt;&lt;strong&gt;(Class Under Test)&lt;/strong&gt; y &lt;em&gt;ReclutarPersonal &lt;/em&gt;&lt;strong&gt;(Class Under Test)&lt;/strong&gt;, y ambas clases dependen de un implementación de &lt;em&gt;IEmpresaRepository&lt;/em&gt; &lt;strong&gt;(Other Class)&lt;/strong&gt; para persistir la información. &lt;/p&gt;      &lt;p align="justify"&gt;Estos Test Doubles los podemos identificar fácilmente ya que son los objetos que tienen los nombres más raros de todo el ejemplo: &lt;em&gt;mockEmpresaRepository&lt;/em&gt; y &lt;em&gt;stubEmpresaRepository&lt;/em&gt;.&lt;/p&gt;      &lt;p align="justify"&gt;Pero, ¿porqué uno se llama mock y el otro stub ? Para darnos cuenta entre la diferencia que tienen, podríamos definirlos de manera muy simple:&lt;/p&gt;      &lt;ul&gt;       &lt;li&gt;         &lt;div align="justify"&gt;&lt;strong&gt;Mock&lt;/strong&gt;: Es el Test Double sobre el cuál realizamos un Assert. Ejm:             &lt;br /&gt;&lt;em&gt;mockEmpresaRepository.AssertWasCalled(x =&amp;gt; x.Agregar(empresa));&lt;/em&gt;             &lt;br /&gt;Estamos verificamos que el método Agregar del IEmpresaRepository se ha llamado dentro del método que estamos probando. &lt;/div&gt;          &lt;br /&gt;&lt;/li&gt;        &lt;li&gt;         &lt;div align="justify"&gt;&lt;strong&gt;Stub&lt;/strong&gt;: Es el Test Double que nos permite poder realizar el test. Ejm:             &lt;br /&gt;&lt;em&gt;stubEmpresaRepository.Expect(x =&amp;gt; x.Obtener(idEmpresa)).Return(empresa); &lt;/em&gt;            &lt;br /&gt;Estamos indicando que cuando se llame el método Obtener del IEmpresaRepository nos devuelva una empresa cualquiera y así la prueba del método pueda continuar.&lt;/div&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Bueno, hasta aquí hemos visto algunos temas del video, pero aún nos falta otros que dejaremos para un siguiente post. Espero les sirva de algo mi pequeño granito de arena. Y les prometo mejorar mi redacción.&lt;/p&gt; No se olviden de ver el resto de las serie &lt;a href="http://snahider.blogspot.com/2010/03/aspnet-mvc-series.html" target="_blank"&gt;ASP.NET MVC y otras Yerbas&lt;/a&gt;.   &lt;br /&gt;Saludos.     </content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/3685407457202066809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/876077106867749026/posts/default/3685407457202066809'/><link rel='alternate' type='text/html' href='http://snahider.blogspot.com/2009/12/aspnet-mvc-y-otras-yerbas-parte-4.html' title='ASP.NET MVC y otras Yerbas – Parte 4'/><author><name>Angel Nuñez Salazar</name><uri>http://www.blogger.com/profile/02183167834235724772</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://3.bp.blogspot.com/-ANiCqstw7nk/UTiCJJt80mI/AAAAAAAAAkI/g2fuGIOfg94/s220/Angel.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_Je6WwZtSU6Q/Syh0Z5t0eeI/AAAAAAAAADY/fralSOJcVDo/s72-c/image_thumb3.png?imgmax=800' height='72' width='72'/></entry></feed>