public ActionResult Create(CategoryModel model) { try { if (ModelState.IsValid) { unitOfWork.CategoryRepository.Insert(model); unitOfWork.Save(); return RedirectToAction("Index"); } return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(int id, CategoryModel model) { try { if (ModelState.IsValid) { var _data = unitOfWork.CategoryRepository.GetByID(model.ID); _data.IsActive = model.IsActive; _data.Name = model.Name; _data.Detail = model.Detail; _data.LastUpdate = DateTime.Now; _data.PerentCategoryID = model.PerentCategoryID; unitOfWork.CategoryRepository.Update(_data); unitOfWork.Save(); return RedirectToAction("Index"); } return RedirectToAction("Index"); } catch { return View(); } }