Mercurial > altnet-hispano
changeset 275:bf993f99cee3
Ticket #123: Patrocinadores de las vans.
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Domain/Repositories/IPatrocinadorRepository.cs Wed Nov 30 08:56:01 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/Repositories/IPatrocinadorRepository.cs Wed Dec 14 08:15:44 2011 -0300 @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace AltNetHispano.Agendas.Domain.Repositories { @@ -7,5 +8,6 @@ void Save(Patrocinador patrocinador); Patrocinador Get(Guid patrocinadorId); void Delete(Patrocinador patrocinador); + IEnumerable<Patrocinador> GetAll(); } } \ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Factories/AgendaFactory.cs Wed Nov 30 08:56:01 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Factories/AgendaFactory.cs Wed Dec 14 08:15:44 2011 -0300 @@ -1,4 +1,5 @@ -using Agendas.Blog.Impl; +using System; +using Agendas.Blog.Impl; using Agendas.NHibernate; using AltNetHispano.Agendas.Domain; using AltNetHispano.Agendas.Domain.Repositories; @@ -44,5 +45,11 @@ { return new PersonaService(GetPersonaRepository(), GetEventoRespository()); } + + public static IPatrocinadorRepository GetPatrocinadorRepository() + { + ISessionFactory sessionFactory = NhHelper.GetSessionFactory(); + return new PatrocinadorRepository(sessionFactory); + } } } \ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Repositories.Memory/PatrocinadorRepository.cs Wed Nov 30 08:56:01 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Repositories.Memory/PatrocinadorRepository.cs Wed Dec 14 08:15:44 2011 -0300 @@ -1,4 +1,7 @@ -using AltNetHispano.Agendas.Domain; +using System; +using System.Collections.Generic; +using System.Linq; +using AltNetHispano.Agendas.Domain; using AltNetHispano.Agendas.Domain.Repositories; namespace AltNetHispano.Agendas.Repositories.Memory @@ -9,5 +12,13 @@ { Objects.Clear(); } + + public IEnumerable<Patrocinador> GetAll() + { + var patrocinadores = Objects.Values.ToList(); + patrocinadores.Sort((first, second) => first.Nombre.CompareTo(second.Nombre)); + + return patrocinadores; + } } } \ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Repositories.NHibernate/PatrocinadorRepository.cs Wed Nov 30 08:56:01 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Repositories.NHibernate/PatrocinadorRepository.cs Wed Dec 14 08:15:44 2011 -0300 @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using AltNetHispano.Agendas.Domain; using AltNetHispano.Agendas.Domain.Repositories; using NHibernate; @@ -21,5 +22,13 @@ { Session.Delete(patrocinador); } + + public IEnumerable<Patrocinador> GetAll() + { + var patrocinadores = Session.QueryOver<Patrocinador>().List(); + ((List<Patrocinador>)patrocinadores).Sort((first, second) => first.Nombre.CompareTo(second.Nombre)); + + return patrocinadores; + } } } \ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Resources/Properties/LayoutResources.Designer.cs Wed Nov 30 08:56:01 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Resources/Properties/LayoutResources.Designer.cs Wed Dec 14 08:15:44 2011 -0300 @@ -169,6 +169,33 @@ } /// <summary> + /// Busca una cadena traducida similar a Descripcion. + /// </summary> + public static string PatrocinadorNewModelDescription { + get { + return ResourceManager.GetString("PatrocinadorNewModelDescription", resourceCulture); + } + } + + /// <summary> + /// Busca una cadena traducida similar a Legenda. + /// </summary> + public static string PatrocinadorNewModelLegend { + get { + return ResourceManager.GetString("PatrocinadorNewModelLegend", resourceCulture); + } + } + + /// <summary> + /// Busca una cadena traducida similar a Titulo. + /// </summary> + public static string PatrocinadorNewModelTitle { + get { + return ResourceManager.GetString("PatrocinadorNewModelTitle", resourceCulture); + } + } + + /// <summary> /// Busca una cadena traducida similar a Modifique los datos que desea corregir y presione guardar. /// </summary> public static string PersonaEditModelDescription {
--- a/Agendas/trunk/src/Agendas.Resources/Properties/LayoutResources.resx Wed Nov 30 08:56:01 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Resources/Properties/LayoutResources.resx Wed Dec 14 08:15:44 2011 -0300 @@ -189,4 +189,13 @@ <data name="PersonaViewModelLegend" xml:space="preserve"> <value>Datos de la persona</value> </data> + <data name="PatrocinadorNewModelDescription" xml:space="preserve"> + <value>Descripcion</value> + </data> + <data name="PatrocinadorNewModelLegend" xml:space="preserve"> + <value>Legenda</value> + </data> + <data name="PatrocinadorNewModelTitle" xml:space="preserve"> + <value>Titulo</value> + </data> </root> \ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Web.Tests/Agendas.Web.Tests.csproj Wed Nov 30 08:56:01 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web.Tests/Agendas.Web.Tests.csproj Wed Dec 14 08:15:44 2011 -0300 @@ -46,6 +46,7 @@ </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> + <Reference Include="System.Drawing" /> <Reference Include="System.Web" /> <Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> <Reference Include="System.Xml.Linq" /> @@ -57,8 +58,11 @@ <ItemGroup> <Compile Include="AutorizationsTests.cs" /> <Compile Include="Controllers\EventoControllerTests.cs" /> + <Compile Include="Controllers\HttpPostedFileBaseModelBinder.cs" /> <Compile Include="Controllers\MvcControllerTestsBase.cs" /> + <Compile Include="Controllers\PatrocinadorControllerTests.cs" /> <Compile Include="Controllers\PersonaControllerTests.cs" /> + <Compile Include="Helpers\HttpServerStub.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> @@ -96,6 +100,9 @@ <ItemGroup> <None Include="packages.config" /> </ItemGroup> + <ItemGroup> + <Folder Include="App_Data\" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets.
--- a/Agendas/trunk/src/Agendas.Web.Tests/AutorizationsTests.cs Wed Nov 30 08:56:01 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web.Tests/AutorizationsTests.cs Wed Dec 14 08:15:44 2011 -0300 @@ -40,7 +40,8 @@ { "HomeController.Index", "HomeController.About", "EventoController.Index", "AccountController.LogOn", "AccountController.LogOff", "AccountController.TwitterLogOn", "HistoricoController.Index", - "PersonaController.Index", "ErrorController.NoAutorizado", "PersonaController.Ver" + "PersonaController.Index", "ErrorController.NoAutorizado", "PersonaController.Ver", + "PatrocinadorController.Index", "PatrocinadorController.GetLogo" }; #region Asserts @@ -93,7 +94,8 @@ "EventoController.Publicar", "EventoController.Modificar", "EventoController.Proponer", "EventoController.Cancelar", "EventoController.Descartar", "EventoController.ReAgendar", "EventoController.ReProponer", "PersonaController.Nueva", "PersonaController.Modificar", - "PersonaController.Quitar", "PersonaApiController.Nueva" + "PersonaController.Quitar", "PersonaApiController.Nueva", "PatrocinadorController.Nuevo", + "PatrocinadorController.Modificar", "PatrocinadorController.Quitar" }; VerficarAccionesSeguras(acciones, Roles.Administrador, "debe ser de uso exclusivo de los administradores");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Web.Tests/Controllers/HttpPostedFileBaseModelBinder.cs Wed Dec 14 08:15:44 2011 -0300 @@ -0,0 +1,70 @@ +using System; +using System.IO; +using System.Web; +using System.Web.Mvc; + +namespace Agendas.Web.Tests.Controllers +{ + public class HttpPostedFileBaseModelBinder : IModelBinder + { + public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) + { + var fileDummy = new HttpFileDummy(((FormCollection)bindingContext.ValueProvider)[bindingContext.ModelName], "image/jpg"); + if (string.IsNullOrEmpty(fileDummy.FileName)) + { + fileDummy = null; + } + return fileDummy; + } + } + + public class HttpFileDummy : HttpPostedFileBase, IDisposable + { + public override int ContentLength + { + get { return (int)InputStream.Length; } + } + + private readonly string _contentType; + public override string ContentType + { + get { return _contentType; } + } + + private readonly string _fileName; + public override string FileName + { + get { return _fileName; } + } + + private FileStream _stream; + public override Stream InputStream + { + get + { + return _stream ?? (_stream = new FileStream(FileName, FileMode.Open, + FileAccess.Read, FileShare.Read)); + } + } + + public HttpFileDummy(string fileName, string contentType) + { + _contentType = contentType; + _fileName = fileName; + } + + public void Dispose() + { + if (_stream != null) + { + try { _stream.Dispose(); } + finally { _stream = null; } + } + } + + public override void SaveAs(string filename) + { + File.WriteAllBytes(filename, File.ReadAllBytes(FileName)); + } + } +}
--- a/Agendas/trunk/src/Agendas.Web.Tests/Controllers/MvcControllerTestsBase.cs Wed Nov 30 08:56:01 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web.Tests/Controllers/MvcControllerTestsBase.cs Wed Dec 14 08:15:44 2011 -0300 @@ -1,12 +1,13 @@ using System.Web; using System.Web.Mvc; +using System.Web.Routing; using Moq; namespace Agendas.Web.Tests.Controllers { public class MvcControllerTestsBase { - protected ControllerContext ControllerCtx = new ControllerContext(); + protected ControllerContext ControllerCtx = new ControllerContext(); protected static TModel BindModel<TModel>(Controller controller, IValueProvider valueProvider) where TModel : class { @@ -21,7 +22,7 @@ ValueProvider = valueProvider }; - return (TModel)binder.BindModel(controller.ControllerContext, bindingContext); + return (TModel)binder.BindModel(controller.ControllerContext, bindingContext); } } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Web.Tests/Controllers/PatrocinadorControllerTests.cs Wed Dec 14 08:15:44 2011 -0300 @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Web; +using System.Web.Mvc; +using System.Web.Routing; +using Agendas.NHibernate; +using Agendas.Repositories.Tests.Infraestructure; +using Agendas.Web.Tests.Helpers; +using AltNetHispano.Agendas.Web.Controllers; +using AltNetHispano.Agendas.Web.Models; +using Moq; +using NUnit.Framework; +using System.Drawing; + +namespace Agendas.Web.Tests.Controllers +{ + [TestFixture] + public class PatrocinadorControllerTests : MvcControllerTestsBase + { + [SetUp] + public void RegisterBinders() + { + ModelBinders.Binders[typeof(HttpPostedFileBase)] = new HttpPostedFileBaseModelBinder(); + } + + [Test] + public void PatrocinadorIndexGet() + { + var patrocinadorController = new PatrocinadorController(new HttpServerStub()) + { + ControllerContext = ControllerCtx + }; + using (new RequestEmulator(NhHelper.GetSessionFactory())) + { + var resultIndex = patrocinadorController.Index(); + Assert.IsInstanceOf(typeof(ViewResult), resultIndex); + Assert.AreEqual("", ((ViewResult)resultIndex).ViewName); + } + } + + [Test] + public void PatrocinadorNuevoGet() + { + var patrocinadorController = new PatrocinadorController(new HttpServerStub()) + { + ControllerContext = ControllerCtx + }; + using (new RequestEmulator(NhHelper.GetSessionFactory())) + { + var resultNuevo = patrocinadorController.Nuevo(); + Assert.IsInstanceOf(typeof(ViewResult), resultNuevo); + Assert.AreEqual("DefaultEditor", ((ViewResult)resultNuevo).ViewName); //UploadFileEditor + } + } + + [Test] + public void PatrocinadorNuevoPostSatisfactorio() + { + var patrocinadorController = new PatrocinadorController(new HttpServerStub()) + { + ControllerContext = ControllerCtx + }; + var form = new FormCollection + { + {"Nombre", "APRESS"}, + {"Logo", @"images\apress.gif"} + }; + var patrocinadorNew = BindModel<PatrocinadorNewModel>(patrocinadorController, form); + + using (new RequestEmulator(NhHelper.GetSessionFactory())) + { + var resultNuevo = patrocinadorController.Nuevo(patrocinadorNew); + Assert.IsInstanceOf(typeof(RedirectToRouteResult), resultNuevo); + var viewResultNuevo = (RedirectToRouteResult)resultNuevo; + Assert.AreEqual("Index", viewResultNuevo.RouteValues["action"]); + } + } + + [Test] + public void PatrocinadorNuevoPostRequiredFields() + { + var patrocinadorController = new PatrocinadorController(new HttpServerStub()) + { + ControllerContext = ControllerCtx + }; + var form = new FormCollection + { + {"Nombre", ""}, + {"Logo", "" } + }; + var patrocinadorNew = BindModel<PatrocinadorNewModel>(patrocinadorController, form); + + using (new RequestEmulator(NhHelper.GetSessionFactory())) + { + var resultNuevo = patrocinadorController.Nuevo(patrocinadorNew); + Assert.IsInstanceOf(typeof(ViewResult), resultNuevo); + var viewResultNuevo = (ViewResult)resultNuevo; + Assert.AreEqual("DefaultEditor", viewResultNuevo.ViewName); //UploadFileEditor + Assert.AreEqual(1, viewResultNuevo.ViewData.ModelState["Nombre"].Errors.Count); + Assert.AreEqual("El campo Nombre es obligatorio.", viewResultNuevo.ViewData.ModelState["Nombre"].Errors[0].ErrorMessage); + Assert.AreEqual(1, viewResultNuevo.ViewData.ModelState["Logo"].Errors.Count); + Assert.AreEqual("El campo Logo es obligatorio.", viewResultNuevo.ViewData.ModelState["Logo"].Errors[0].ErrorMessage); + } + } + + [Test] + [Ignore] + public void PatrocinadorNuevoPostExistente() + { + + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Web.Tests/Helpers/HttpServerStub.cs Wed Dec 14 08:15:44 2011 -0300 @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using AltNetHispano.Agendas.Web.Services; + +namespace Agendas.Web.Tests.Helpers +{ + public class HttpServerStub: IHttpServer + { + public string MapPath(string path) + { + var directory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); + +#if DEBUG + if (directory.Parent != null && directory.Parent.Parent != null) + directory = directory.Parent.Parent; +#endif + + return path.Replace("~", directory.FullName); + } + } +}
--- a/Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj Wed Nov 30 08:56:01 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj Wed Dec 14 08:15:44 2011 -0300 @@ -67,6 +67,7 @@ <Compile Include="Controllers\EventoController.cs" /> <Compile Include="Controllers\HistoricoController.cs" /> <Compile Include="Controllers\HomeController.cs" /> + <Compile Include="Controllers\PatrocinadorController.cs" /> <Compile Include="Controllers\PerfilController.cs" /> <Compile Include="Controllers\PersonaApiController.cs" /> <Compile Include="Controllers\PersonaController.cs" /> @@ -83,12 +84,14 @@ <Compile Include="Models\EventoModel.cs" /> <Compile Include="Models\EventoModelHelper.cs" /> <Compile Include="Models\HistoricoModel.cs" /> + <Compile Include="Models\PatrocinadorModel.cs" /> <Compile Include="Models\PerfilModel.cs" /> <Compile Include="Models\PersonaModel.cs" /> <Compile Include="Models\PropuestaModel.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Services\FormsAuthenticationService.cs" /> <Compile Include="Services\IFormsAuthenticationService.cs" /> + <Compile Include="Services\IHttpServer.cs" /> </ItemGroup> <ItemGroup> <Content Include="Content\AltNetHispanoVans.css" /> @@ -249,6 +252,12 @@ <ItemGroup> <Content Include="Views\Shared\DefaultViewer.cshtml" /> </ItemGroup> + <ItemGroup> + <Content Include="Views\Patrocinador\Index.cshtml" /> + </ItemGroup> + <ItemGroup> + <Content Include="Views\Shared\EditorTemplates\HttpPostedFileBase.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.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Web/Controllers/PatrocinadorController.cs Wed Dec 14 08:15:44 2011 -0300 @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using AltNetHispano.Agendas.Domain; +using AltNetHispano.Agendas.Factories; +using AltNetHispano.Agendas.Web.Models; +using AltNetHispano.Agendas.Web.Services; + + +namespace AltNetHispano.Agendas.Web.Controllers +{ + public class PatrocinadorController : Controller + { + private IHttpServer _server; + + public PatrocinadorController() + { + _server = (IHttpServer)ControllerContext.HttpContext.Server; + } + + public PatrocinadorController(IHttpServer server) + { + _server = server; + } + + public ActionResult GetLogo(string id) + { + var patrocinadores = AgendaFactory.GetPatrocinadorRepository(); + + var patrocinador = patrocinadores.Get(new Guid(id)); + + return File(patrocinador.Logo, "image/jpg"); + } + + public ActionResult Index() + { + var patrocinadores = AgendaFactory.GetPatrocinadorRepository(); + + var model = new PatrocinadorIndexModel + { + Items = from p in patrocinadores.GetAll() + select new PatrocinadorDto + { + Id = p.Id, + Nombre = p.Nombre + } + }; + + return View(model); + } + + [CustomAuthorize(Roles = Roles.Administrador)] + public ActionResult Nuevo() + { + var model = new PatrocinadorNewModel(); + return View("DefaultEditor", model); + } + + [HttpPost] + [CustomAuthorize(Roles = Roles.Administrador)] + public ActionResult Nuevo(PatrocinadorNewModel model) + { + if (ModelState.IsValid) + { + var tempLogoFile = Path.Combine(_server.MapPath("~/App_Data"), model.Nombre + model.Logo.FileName.Substring(model.Logo.FileName.LastIndexOf("."))); + model.Logo.SaveAs(tempLogoFile); + + var patrocinadores = AgendaFactory.GetPatrocinadorRepository(); + + var patrocinador = new Patrocinador(model.Nombre); + patrocinador.LoadLogo(tempLogoFile); + + patrocinadores.Save(patrocinador); + + return RedirectToAction("Index"); + } + + return View("DefaultEditor", model); + } + + [CustomAuthorize(Roles = Roles.Administrador)] + public ActionResult Modificar(int id) + { + return View(); + } + + [HttpPost] + [CustomAuthorize(Roles = Roles.Administrador)] + public ActionResult Modificar(int id, FormCollection collection) + { + try + { + // TODO: Add update logic here + + return RedirectToAction("Index"); + } + catch + { + return View(); + } + } + + [CustomAuthorize(Roles = Roles.Administrador)] + public ActionResult Quitar(int id) + { + return View(); + } + + } +}
--- a/Agendas/trunk/src/Agendas.Web/Global.asax.cs Wed Nov 30 08:56:01 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Global.asax.cs Wed Dec 14 08:15:44 2011 -0300 @@ -1,4 +1,5 @@ -using System.Web.Mvc; +using System.Web; +using System.Web.Mvc; using System.Web.Routing; using AltNetHispano.Agendas.Domain; using AltNetHispano.Agendas.Factories;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Web/Models/PatrocinadorModel.cs Wed Dec 14 08:15:44 2011 -0300 @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.IO; +using System.Linq; +using System.Web; +using System.Web.Mvc; + +namespace AltNetHispano.Agendas.Web.Models +{ + public class PatrocinadorIndexModel + { + public IEnumerable<PatrocinadorDto> Items { get; set; } + } + + public class PatrocinadorDto + { + public Guid Id { get; set; } + public string Nombre { get; set; } + + } + + public class PatrocinadorNewModel + { + [Required] + public string Nombre { get; set; } + + [Required] + public HttpPostedFileBase Logo { get; set; } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Web/Services/IHttpServer.cs Wed Dec 14 08:15:44 2011 -0300 @@ -0,0 +1,7 @@ +namespace AltNetHispano.Agendas.Web.Services +{ + public interface IHttpServer + { + string MapPath(string path); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Web/Views/Patrocinador/Index.cshtml Wed Dec 14 08:15:44 2011 -0300 @@ -0,0 +1,34 @@ +@model AltNetHispano.Agendas.Web.Models.PatrocinadorIndexModel +<h2>Agenda</h2> +<p> + Los Patrocinadores son: +</p> +<div id="content"> + <table> + <thead> + <tr> + <th></th> + <th>Patrocinador</th> + <th>Acciones</th> + </tr> + </thead> + <tbody> + @foreach (var item in Model.Items) + { + <tr> + <td><img src="/Patrocinador/GetLogo?id=@item.Id" /></td> + <td>@item.Nombre</td> + <td> + @Html.ActionLink("Modificar", "Modificar", new { id = item.Id }) + <span> </span> + @Html.ActionLink("Eliminar", "Eliminar", new { id = item.Id }, new { @class = "ui-button-confirm" }) + <span> </span> + </td> + </tr> + } + </tbody> + </table> +</div> +<div class="buttons"> + @Html.ActionLink("Nuevo", "Nuevo") +</div>
--- a/Agendas/trunk/src/Agendas.Web/Views/Shared/DefaultEditor.cshtml Wed Nov 30 08:56:01 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Views/Shared/DefaultEditor.cshtml Wed Dec 14 08:15:44 2011 -0300 @@ -19,7 +19,16 @@ }); </script> -@using (Html.BeginForm()) +@using (Html.BeginForm( + null, + null, + FormMethod.Post, + (ViewData.ModelMetadata.Properties.Count(p => p.ModelType.Name == "HttpPostedFileBase") > 0 ? + new { enctype = "multipart/form-data" } : + null + ) + ) + ) { @Html.ValidationSummary(true) <div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Web/Views/Shared/EditorTemplates/HttpPostedFileBase.cshtml Wed Dec 14 08:15:44 2011 -0300 @@ -0,0 +1,2 @@ +@model HttpPostedFileBase +<input type="file" id="@Html.ViewData.ModelMetadata.PropertyName" name="@Html.ViewData.ModelMetadata.PropertyName" />