public ActionResult CreateCanton(Cantonx cantonToCreate) { try { _entities.AddToCanton(cantonToCreate); _entities.SaveChanges(); return(RedirectToAction("GetAllCantons")); } catch { return(View()); } }
public ActionResult DeleteCanton(Cantonx cantonToDelete) { cantonToDelete = _entities.Canton.First(m => m.Id == cantonToDelete.Id); if (!ModelState.IsValid) { return(View(cantonToDelete)); } _entities.DeleteObject(cantonToDelete); _entities.SaveChanges(); return(RedirectToAction("GetAllCantons")); }
public ActionResult CCanton(Cantonx CantonToCreate) { try { // TODO: Add insert logic here _entities.AddToCanton(CantonToCreate); _entities.SaveChanges(); return(RedirectToAction("DCanton")); } catch { return(View()); } }
public ActionResult BCanton(Cantonx CantonToDelete) { var originalCanton = (from m in _entities.Distrito where m.Id == CantonToDelete.Id select m).First(); if (!ModelState.IsValid) { return(View(originalCanton)); } _entities.DeleteObject(CantonToDelete); _entities.SaveChanges(); return(RedirectToAction("DCanton")); }
public ActionResult EditCanton(Cantonx cantonToEdit) { // TODO: Add update logic here var originalCanton = (from m in _entities.Canton where m.Id == cantonToEdit.Id select m).First(); if (!ModelState.IsValid) { return(View(originalCanton)); } _entities.ApplyCurrentValues(originalCanton.EntityKey.EntitySetName, cantonToEdit); _entities.SaveChanges(); return(RedirectToAction("GetAllCantons")); }