public ActionResult Create(CategoryViewModel category) { if (ModelState.IsValid) { var toSave = Mapper.Map<Category>(category); unitOfWork.CategoryRepository.Insert(toSave); unitOfWork.Save(); return RedirectToAction("Index"); } return View(category); }
public ActionResult Edit(CategoryViewModel category) { if (ModelState.IsValid) { var entityToUpdate = Mapper.Map<Category>(category); unitOfWork.CategoryRepository.Update(entityToUpdate); unitOfWork.Save(); return RedirectToAction("Index"); } return this.View(category); }