Mercurial > altnet-hispano
view Agendas/trunk/src/Agendas.Web/Controllers/AgendaController.cs @ 12:05996fa19e04
Unificamos Van y Cafe en Evento
Agenda.Publicar con los valores como parámetros independientes
author | nelo@MTEySS.neluz.int |
---|---|
date | Sun, 13 Mar 2011 19:50:17 -0300 |
parents | c62b77fc33f4 |
children | ed6d842abf42 |
line wrap: on
line source
using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using Agendas.Web.Models; using AltNetHispano.Agendas.Domain; using AltNetHispano.Agendas.Domain.Exceptions; namespace Agendas.Web.Controllers { public class AgendaController : Controller { public ActionResult Index() { var model = GetIndexModel(); return View(model); } private static AgendaIndexModel GetIndexModel() { var agenda = AgendaFactory.GetAgenda(); return new AgendaIndexModel { ProximosEventos = from e in agenda.GetEventosPublicados() select new EventoDto {Id = e.Id.ToString(), Titulo = e.Titulo} }; } public ActionResult New() { return View(); } [HttpPost] public ActionResult New(AgendaNewModel model) { if (ModelState.IsValid) { var agenda = AgendaFactory.GetAgenda(); try { agenda.Publicar(model.Titulo, model.Ponente, model.Fecha); return View("Index", GetIndexModel()); } catch (ValidationException ex) { ModelState.AddModelError("error", ex.ToString()); } } return View(model); } } }