public ActionResult AddCategory([Bind(Exclude = "CategoryId")] CategoryViewModel category) { string userId = User.Identity.GetUserId(); Category categoryEntity = new Category { Name = category.Name, ApplicationUserId = userId }; try { this.categoryService.AddCategory(categoryEntity); } catch (ValidationException ex) { ExceptionBindingInMS.AddModelErrors(this.ModelState, ex); return View("_CategoryList"); } category.CategoryId = categoryEntity.CategoryId; return PartialView("_Category", category); }
public void AddCategory(Category category) { this.validationProvider.Validate(category); this.categoryRepository.Insert(category); }