public ActionResult EditCategory(Category editCategory) { if (ModelState.IsValid) { context.Entry(editCategory).State = EntityState.Modified; context.SaveChanges(); return RedirectToAction("ShowCategory"); } return PartialView("_EditCategory",editCategory); }
public ActionResult NewCategory(Category newCategory) { try { if (ModelState.IsValid) { context.Categories.Add(newCategory); context.SaveChanges(); return RedirectToAction("ShowCategory"); } } catch (DataException) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return PartialView("_NewCategory"); }