public ActionResult DeleteInfante(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InfanteRepository InfanRepo = new InfanteRepository(); if (InfanRepo.DeleteInfante(id)) { ViewBag.AlertMsg = "Infante eliminado"; } else { ViewBag.AlertMsg = "No se puedo eliminar"; } return(RedirectToAction("GetInfantes")); } catch { return(RedirectToAction("GetInfantes")); } }
public ActionResult EditInfante(Infante obj) { try { if (ModelState.IsValid) { InfanteRepository InfanRepo = new InfanteRepository(); if (InfanRepo.UpdateInfante(obj)) { ViewBag.Message = "Infante modificado"; } else { ViewBag.Message = "Ocurrio un error"; } return(RedirectToAction("GetInfantes")); } return(View(obj)); } catch { return(RedirectToAction("GetInfantes")); } }
public ActionResult GetInfantes() { InfanteRepository InfanRepo = new InfanteRepository(); ModelState.Clear(); return(View(InfanRepo.ListarInfantes())); }
public ActionResult EditInfante(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } InfanteRepository InfanRepo = new InfanteRepository(); Infante result = InfanRepo.ListarInfantes() .Find(Inf => Inf.Infante_ID == id); if (result == null) { return(HttpNotFound()); } return(View(result)); }
public ActionResult AddInfante(Infante inf) { try { if (ModelState.IsValid) { InfanteRepository InfanRepo = new InfanteRepository(); if (InfanRepo.AddInfante(inf)) { ViewBag.Message = "Infante agregado"; } else { ViewBag.Message = "Ocurrio un error"; } } return(RedirectToAction("GetInfantes")); } catch { return(View()); } }