public ActionResult CreateCategory(Category category) { if (_categoryService.GetAll().Count(c => c.Name == category.Name) > 0) return RedirectToAction("Create", new RouteValueDictionary { { "id", null}, { "createError", true } }); if (ModelState.IsValid) { _categoryService.Insert(category); return RedirectToAction("Index"); } return View(category); }
public ActionResult Delete(int id, Category model) { try { var category = _categoryService.GetById(id); _categoryService.Delete(category); } catch (DataException) { return RedirectToAction("Delete", new RouteValueDictionary { { "id", id }, { "saveChangesError", true } }); } return RedirectToAction("Index"); }
public void Update(Category model) { if (model == null) throw new ArgumentNullException("category"); categoryRepository.Update(model); }
public ActionResult Edit(Category model) { if (ModelState.IsValid) { _categoryService.Update(model); return RedirectToAction("Index"); } return View(model); }