public ActionResult Edit(Organization model) { try { PMISContext db = new PMISContext(); var org = db.Organizations.Where(x => x.ID == model.ID).SingleOrDefault(); db.Entry(org).CurrentValues.SetValues(model); db.SaveChanges(); TempData["EDIT_STATE"] = "OK"; return(RedirectToAction("Index")); } catch (Exception e) { TempData["EDIT_STATE"] = "FAIL"; return(RedirectToAction("Index")); } }
public ActionResult Edit(Person model) { try { if (ModelState.IsValid) { PMISContext db = new PMISContext(); var org = db.Persons.Where(x => x.ID == model.ID).SingleOrDefault(); db.Entry(org).CurrentValues.SetValues(model); db.SaveChanges(); TempData["EDIT_STATE"] = "OK"; return(RedirectToAction("Index")); } else { return(View(model)); } } catch (Exception e) { TempData["EDIT_STATE"] = "FAIL"; return(RedirectToAction("Index")); } }