comparison Agendas/trunk/src/Agendas.Web/Controllers/AgendaController.cs @ 14:ed6d842abf42

Modificar evento
author nelo@MTEySS.neluz.int
date Sun, 13 Mar 2011 20:49:15 -0300
parents 05996fa19e04
children 08b9e96132a5
comparison
equal deleted inserted replaced
13:da95298db862 14:ed6d842abf42
50 ModelState.AddModelError("error", ex.ToString()); 50 ModelState.AddModelError("error", ex.ToString());
51 } 51 }
52 } 52 }
53 return View(model); 53 return View(model);
54 } 54 }
55
56 public ActionResult Edit(string id)
57 {
58 var agenda = AgendaFactory.GetAgenda();
59 var evento = agenda.GetEventoPublicado(new Guid(id));
60 if (evento!=null)
61 {
62 var model = new AgendaEditModel {Id = id, Titulo = evento.Titulo, Ponente = evento.Ponente, Fecha = evento.Fecha};
63 return View(model);
64 }
65 ModelState.AddModelError("error","No se encontrĂ³ el evento que quiere modificar");
66 return View();
67 }
68
69 [HttpPost]
70 public ActionResult Edit(AgendaEditModel model)
71 {
72 if (ModelState.IsValid)
73 {
74 var agenda = AgendaFactory.GetAgenda();
75
76 try
77 {
78 agenda.ModificarEvento(new Guid(model.Id), model.Titulo, model.Ponente, model.Fecha);
79
80 return View("Index", GetIndexModel());
81 }
82 catch (ValidationException ex)
83 {
84 ModelState.AddModelError("error", ex.ToString());
85 }
86 }
87 return View(model);
88 }
55 } 89 }
56 } 90 }