public ActionResult CreateMainCode(MainCategory model)
        {
            if (ModelState.IsValid)
            {
                model.IsMenu = false;
                try
                {
                    if (_categoryService.GetCategory(model.Code) == null)
                    {
                        _categoryService.CreateCategory(model);
                        _categoryService.SaveCategory();
                        return RedirectToAction("Index");
                    }
                    else
                    {
                        ModelState.AddModelError("Code", ErrorMessages.CATEGORYCODE_EXIST);
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", e);
                }

            }
            return View(model);
        }
示例#2
0
 public IEnumerable<SubCategory> GetSubCategories(MainCategory mainCategory, ApplicationUser user)
 {
     throw new NotImplementedException();
 }