// // GET: /Administration/Category/Edit/5 public ActionResult Edit(int id) { CategoryService service = new CategoryService(); Category cat = service.GetById(id); EditCategoryModel model = new EditCategoryModel() { Id = cat.CategoryID, Name =cat.CategoryName, ParentCategoryID =cat.ParentCategoryID, AccessTypes = cat.AccessTypes }; return View(model); }
public ActionResult Edit(int id, EditCategoryModel model) { try { CategoryService service = new CategoryService(); if (ModelState.IsValid) { service.Edit(id, model.Name, model.ParentCategoryID, model.AccessTypes); return RedirectToAction("Index"); } } catch(Exception ex) { ModelState.AddModelError("Error", ex); } return View(model); }