public ActionResult Create(CreateCategoryPostRequest category)
        {
            var user = User.Identity.GetUserName();

            category.CreateBy = User.Identity.GetUserName();
            if (ModelState.IsValid)
            {
                if (User.IsInRole("Administrator"))
                {
                    category.Status = (int)Define.Status.Active;
                }
                else
                {
                    category.Status = (int)Define.Status.WaitingCreate;
                }
                bool isSuccess = categoryService.AddCategory(category);
                if (isSuccess)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("Server error", "Add new category fail.");
                }
            }

            return(View(category));
        }
Exemple #2
0
        public ActionResult Create(CreateCategoryPostRequest category)
        {
            if (ModelState.IsValid)
            {
                bool isSuccess = categoryService.AddCategory(category);
                if (isSuccess)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("Server error", "Add new category fail.");
                }
            }

            return(View(category));
        }