public ActionResult DeleteConfirmed(int id) { StatusFicha statusFicha = db.StatusFichas.Find(id); db.StatusFichas.Remove(statusFicha); try { db.SaveChanges(); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException.InnerException != null && ex.InnerException.InnerException.Message.Contains("REFERENCE")) { ModelState.AddModelError(string.Empty, "the register not can't delete because have relations active"); } else { ModelState.AddModelError(string.Empty, ex.Message); } return(View(statusFicha)); } return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "id_Status_Ficha,name_State,Status")] StatusFicha statusFicha) { if (ModelState.IsValid) { db.Entry(statusFicha).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(statusFicha)); }
public ActionResult Create([Bind(Include = "id_Status_Ficha,name_State,Status")] StatusFicha statusFicha) { if (ModelState.IsValid) { db.StatusFichas.Add(statusFicha); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(statusFicha)); }
// GET: StatusFichas/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StatusFicha statusFicha = db.StatusFichas.Find(id); if (statusFicha == null) { return(HttpNotFound()); } return(View(statusFicha)); }