public ActionResult Create() { var CategoryEdit = new CategoryEdit { }; return View(CategoryEdit); }
public ActionResult Create(CategoryEdit categoryEdit) { if (_categoryQueryService.IsCodeUnique(categoryEdit.Code, categoryEdit.Id)) ModelState.AddModelError("Code", "Category code must be unique"); if (!ModelState.IsValid) { return View(categoryEdit); } var categoryUpdate = Mapper.Map<CategoryUpdate>(categoryEdit); _categoryCommandService.Add(categoryUpdate); TempData["Info"] = "Category Added"; return RedirectToRoute("admin-categories", new { categoryEdit.Id }); }