Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Web/Controllers/EventoController.cs @ 27:29b8a8893ba3
Mejoras menores en UI
author | nelo@MTEySS.neluz.int |
---|---|
date | Tue, 15 Mar 2011 09:14:52 -0300 |
parents | 71b02443450a |
children | 475be11edf56 |
comparison
equal
deleted
inserted
replaced
26:71b02443450a | 27:29b8a8893ba3 |
---|---|
9 { | 9 { |
10 public class EventoController : Controller | 10 public class EventoController : Controller |
11 { | 11 { |
12 public ActionResult Index() | 12 public ActionResult Index() |
13 { | 13 { |
14 var model = GetIndexModel(); | 14 var agenda = AgendaFactory.GetAgenda(); |
15 | |
16 var model = new EventoIndexModel | |
17 { | |
18 ProximosEventos = from e in agenda.GetEventosPublicados() | |
19 select new EventoDto { Id = e.Id.ToString(), Titulo = e.Titulo } | |
20 }; | |
21 | |
15 return View(model); | 22 return View(model); |
16 } | |
17 | |
18 private static EventoIndexModel GetIndexModel() | |
19 { | |
20 var agenda = AgendaFactory.GetAgenda(); | |
21 | |
22 return new EventoIndexModel | |
23 { | |
24 ProximosEventos = from e in agenda.GetEventosPublicados() | |
25 select new EventoDto {Id = e.Id.ToString(), Titulo = e.Titulo} | |
26 }; | |
27 } | 23 } |
28 | 24 |
29 [Authorize] | 25 [Authorize] |
30 public ActionResult New() | 26 public ActionResult New() |
31 { | 27 { |
42 | 38 |
43 try | 39 try |
44 { | 40 { |
45 agenda.Publicar(model.Titulo, model.Ponente, model.Fecha); | 41 agenda.Publicar(model.Titulo, model.Ponente, model.Fecha); |
46 | 42 |
47 return View("Index", GetIndexModel()); | 43 return RedirectToAction("Index"); |
48 } | 44 } |
49 catch (ValidationException ex) | 45 catch (ValidationException ex) |
50 { | 46 { |
51 ModelState.AddModelError("error", ex.ToString()); | 47 ModelState.AddModelError("error", ex.ToString()); |
52 } | 48 } |
84 | 80 |
85 try | 81 try |
86 { | 82 { |
87 agenda.ModificarEvento(new Guid(model.Id), model.Titulo, model.Ponente, model.Fecha); | 83 agenda.ModificarEvento(new Guid(model.Id), model.Titulo, model.Ponente, model.Fecha); |
88 | 84 |
89 return View("Index", GetIndexModel()); | 85 return RedirectToAction("Index"); |
90 } | 86 } |
91 catch (ValidationException ex) | 87 catch (ValidationException ex) |
92 { | 88 { |
93 ModelState.AddModelError("error", ex.ToString()); | 89 ModelState.AddModelError("error", ex.ToString()); |
94 } | 90 } |