changeset 141:a5ff4de4a1d3

EditorForModel en Nuevo Evento y Proponer
author Nelo@Guinea.neluz.int
date Mon, 01 Aug 2011 00:10:20 -0300
parents 3639803112c6
children 62dc9fb3a03e
files Agendas/trunk/src/Agendas.Resources/Properties/DataAnnotationResources.Designer.cs Agendas/trunk/src/Agendas.Resources/Properties/DataAnnotationResources.resx Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj Agendas/trunk/src/Agendas.Web/Controllers/EventoController.cs Agendas/trunk/src/Agendas.Web/DataProviders.cs Agendas/trunk/src/Agendas.Web/Models/EventoModel.cs Agendas/trunk/src/Agendas.Web/Models/EventoModelHelper.cs Agendas/trunk/src/Agendas.Web/Models/PropuestaModel.cs Agendas/trunk/src/Agendas.Web/Views/Evento/Nuevo.cshtml Agendas/trunk/src/Agendas.Web/Views/Evento/Proponer.cshtml Agendas/trunk/src/Agendas.Web/Views/Shared/EditorTemplates/TipoEvento.cshtml
diffstat 11 files changed, 66 insertions(+), 105 deletions(-) [+]
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Resources/Properties/DataAnnotationResources.Designer.cs	Fri Jul 29 16:30:53 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Resources/Properties/DataAnnotationResources.Designer.cs	Mon Aug 01 00:10:20 2011 -0300
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:4.0.30319.225
+//     Runtime Version:4.0.30319.235
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
@@ -79,6 +79,24 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Tipo de evento.
+        /// </summary>
+        public static string TipoEvento {
+            get {
+                return ResourceManager.GetString("TipoEvento", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Define las características que tendrá el evento como objetivo, dinámica del evento, etc..
+        /// </summary>
+        public static string TipoEventoDescription {
+            get {
+                return ResourceManager.GetString("TipoEventoDescription", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Título.
         /// </summary>
         public static string Titulo {
--- a/Agendas/trunk/src/Agendas.Resources/Properties/DataAnnotationResources.resx	Fri Jul 29 16:30:53 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Resources/Properties/DataAnnotationResources.resx	Mon Aug 01 00:10:20 2011 -0300
@@ -123,6 +123,12 @@
   <data name="PonenteRequired" xml:space="preserve">
     <value>debe ingresar el nombre del ponente</value>
   </data>
+  <data name="TipoEvento" xml:space="preserve">
+    <value>Tipo de evento</value>
+  </data>
+  <data name="TipoEventoDescription" xml:space="preserve">
+    <value>Define las características que tendrá el evento como objetivo, dinámica del evento, etc.</value>
+  </data>
   <data name="Titulo" xml:space="preserve">
     <value>Título</value>
   </data>
--- a/Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj	Fri Jul 29 16:30:53 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj	Mon Aug 01 00:10:20 2011 -0300
@@ -67,6 +67,7 @@
     <Compile Include="Controllers\HistoricoController.cs" />
     <Compile Include="Controllers\HomeController.cs" />
     <Compile Include="Controllers\PerfilController.cs" />
+    <Compile Include="DataProviders.cs" />
     <Compile Include="Global.asax.cs">
       <DependentUpon>Global.asax</DependentUpon>
     </Compile>
@@ -209,6 +210,9 @@
   <ItemGroup>
     <Content Include="Views\Historico\Index.cshtml" />
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="Views\Shared\EditorTemplates\TipoEvento.cshtml" />
+  </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
--- a/Agendas/trunk/src/Agendas.Web/Controllers/EventoController.cs	Fri Jul 29 16:30:53 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Controllers/EventoController.cs	Mon Aug 01 00:10:20 2011 -0300
@@ -52,7 +52,7 @@
 				var agenda = AgendaFactory.GetAgenda();
 
 				var r = agenda.Agendar(model.Titulo, model.Ponente, model.Fecha,
-				  model.UrlInvitacion, (TipoEvento)model.Tipo);
+				  model.UrlInvitacion, (TipoEvento)model.TipoEvento);
 				if (r.Succeful)
 				{
 					this.AddNotification("Datos guardados");
@@ -169,7 +169,7 @@
 			{
 				var agenda = AgendaFactory.GetAgenda();
 
-				var r = agenda.Proponer(model.Titulo, model.Ponente, model.UrlInvitacion, (TipoEvento)model.Tipo);
+				var r = agenda.Proponer(model.Titulo, model.Ponente, model.UrlInvitacion, (TipoEvento)model.TipoEvento);
 				if (r.Succeful)
 					return RedirectToAction("Index");
 				ModelState.AddModelError("error", r.ToString());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Web/DataProviders.cs	Mon Aug 01 00:10:20 2011 -0300
@@ -0,0 +1,16 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Web.Mvc;
+using AltNetHispano.Agendas.Web.Models;
+
+namespace AltNetHispano.Agendas.Web
+{
+    public static class DataProviders
+    {
+        public static IEnumerable<SelectListItem> GetTiposEvento(this HtmlHelper helper)
+        {
+            return from t in EventoModelHelper.GetTiposEventos()
+                   select new SelectListItem {Text = t.TipoEventoStr, Value = t.TipoEvento.ToString()};
+        }
+    }
+}
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Web/Models/EventoModel.cs	Fri Jul 29 16:30:53 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Models/EventoModel.cs	Mon Aug 01 00:10:20 2011 -0300
@@ -13,13 +13,9 @@
 
 	public class EventoNewModel
 	{
-		public EventoNewModel()
-		{
-			Tipos = EventoModelHelper.GetTiposEventos();
-		}
-
 		[Required]
-		public int Tipo { get; set; }
+        [UIHint("TipoEvento")]
+		public int TipoEvento { get; set; }
 
 		[Required]
 		public string Titulo { get; set; }
@@ -32,14 +28,6 @@
 
 		[Url]
 		public string UrlInvitacion { get; set; }
-
-		public IEnumerable<TipoEventoModel> Tipos { get; private set; }
-	}
-
-	public class TipoEventoModel
-	{
-		public int TipoEvento { get; set; }
-		public string TipoEventoStr { get; set; }
 	}
 
 	public class EventoEditModel
--- a/Agendas/trunk/src/Agendas.Web/Models/EventoModelHelper.cs	Fri Jul 29 16:30:53 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Models/EventoModelHelper.cs	Mon Aug 01 00:10:20 2011 -0300
@@ -3,17 +3,23 @@
 
 namespace AltNetHispano.Agendas.Web.Models
 {
-  public static class EventoModelHelper
-  {
-    public static IEnumerable<TipoEventoModel> GetTiposEventos()
+    public static class EventoModelHelper
     {
-      var tipos = new List<TipoEventoModel>
+        public static IEnumerable<TipoEventoModel> GetTiposEventos()
+        {
+            var tipos = new List<TipoEventoModel>
                     {
                       new TipoEventoModel {TipoEvento = (int) TipoEvento.Van, TipoEventoStr = "VAN"},
                       new TipoEventoModel {TipoEvento = (int) TipoEvento.Cafe, TipoEventoStr = "ALT.NET Cafe"},
                       new TipoEventoModel {TipoEvento = (int) TipoEvento.GrupoEstudio, TipoEventoStr = "Grupo Estudio"}
                     };
-      return tipos;
+            return tipos;
+        }
+
+        public class TipoEventoModel
+        {
+            public int TipoEvento { get; set; }
+            public string TipoEventoStr { get; set; }
+        }
     }
-  }
 }
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Web/Models/PropuestaModel.cs	Fri Jul 29 16:30:53 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Models/PropuestaModel.cs	Mon Aug 01 00:10:20 2011 -0300
@@ -7,13 +7,9 @@
 {
 	public class PropuestaNewModel
 	{
-		public PropuestaNewModel()
-		{
-			Tipos = EventoModelHelper.GetTiposEventos();
-		}
-
 		[Required]
-		public int Tipo { get; set; }
+        [UIHint("TipoEvento")]
+		public int TipoEvento { get; set; }
 
 		[Required]
 		public string Titulo { get; set; }
@@ -22,7 +18,5 @@
 
 		[Url]
 		public string UrlInvitacion { get; set; }
-
-		public IEnumerable<TipoEventoModel> Tipos { get; private set; }
 	}
 }
\ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Web/Views/Evento/Nuevo.cshtml	Fri Jul 29 16:30:53 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Views/Evento/Nuevo.cshtml	Mon Aug 01 00:10:20 2011 -0300
@@ -22,47 +22,7 @@
     <div>
         <fieldset>
             <legend>Datos del evento:</legend>
-
-            <div class="editor-label">
-              @Html.LabelFor(model=>model.Tipo)
-            </div>
-            <div class="editor-field">
-              @Html.DropDownListFor(model => model.Tipo, new SelectList(Model.Tipos, "TipoEvento", "TipoEventoStr"))
-              @Html.ValidationMessageFor(model => model.Tipo)
-            </div>
-
-            <div class="editor-label">
-              @Html.LabelFor(model=>model.Titulo)
-            </div>
-            <div class="editor-field">
-              @Html.EditorFor(model=>model.Titulo)
-              @Html.ValidationMessageFor(model => model.Titulo)
-            </div>
-
-            <div class="editor-label">
-              @Html.LabelFor(model=>model.Ponente)
-            </div>
-            <div class="editor-field">
-              @Html.EditorFor(model=>model.Ponente)
-              @Html.ValidationMessageFor(model => model.Ponente)
-            </div>
-
-            <div class="editor-label">
-              @Html.LabelFor(model=>model.Fecha)
-            </div>
-            <div class="editor-field">
-              @Html.EditorFor(model=>model.Fecha)
-              @Html.ValidationMessageFor(model => model.Fecha)
-            </div>
-
-            <div class="editor-label">
-              @Html.LabelFor(model=>model.UrlInvitacion)
-            </div>
-            <div class="editor-field">
-              @Html.EditorFor(model => model.UrlInvitacion)
-              @Html.ValidationMessageFor(model => model.UrlInvitacion)
-            </div>
-
+            @Html.EditorForModel()
             <p>
                 <input type="submit" value="Guardar" />
             </p>
--- a/Agendas/trunk/src/Agendas.Web/Views/Evento/Proponer.cshtml	Fri Jul 29 16:30:53 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Web/Views/Evento/Proponer.cshtml	Mon Aug 01 00:10:20 2011 -0300
@@ -13,39 +13,7 @@
     <div>
         <fieldset>
             <legend>Datos de la propuesta:</legend>
-
-            <div class="editor-label">
-              @Html.LabelFor(model=>model.Tipo)
-            </div>
-            <div class="editor-field">
-              @Html.DropDownListFor(model => model.Tipo, new SelectList(Model.Tipos, "TipoEvento", "TipoEventoStr"))
-              @Html.ValidationMessageFor(model => model.Tipo)
-            </div>
-
-            <div class="editor-label">
-              @Html.LabelFor(model=>model.Titulo)
-            </div>
-            <div class="editor-field">
-              @Html.EditorFor(model=>model.Titulo)
-              @Html.ValidationMessageFor(model => model.Titulo)
-            </div>
-
-            <div class="editor-label">
-              @Html.LabelFor(model=>model.Ponente)
-            </div>
-            <div class="editor-field">
-              @Html.EditorFor(model=>model.Ponente)
-              @Html.ValidationMessageFor(model => model.Ponente)
-            </div>
-
-            <div class="editor-label">
-              @Html.LabelFor(model=>model.UrlInvitacion)
-            </div>
-            <div class="editor-field">
-              @Html.EditorFor(model => model.UrlInvitacion)
-              @Html.ValidationMessageFor(model => model.UrlInvitacion)
-            </div>
-
+            @Html.EditorForModel()
             <p>
                 <input type="submit" value="Guardar" />
             </p>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Agendas/trunk/src/Agendas.Web/Views/Shared/EditorTemplates/TipoEvento.cshtml	Mon Aug 01 00:10:20 2011 -0300
@@ -0,0 +1,1 @@
+@Html.DropDownList(string.Empty, Html.GetTiposEvento())