コード例 #1
0
        public ActionResult CreateNew(Design model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var flag = _designService.CheckContain(model.Name);
                    if (flag)
                    {
                        AlertWarning(InfoString.SetContainString("Tên"));
                        ViewData["ParentCategories"] = _categoryService.GetParents(1);//parent type production
                        return(View(model));
                    }

                    model.CreateBy   = "hadacduong";
                    model.CreateDate = DateTime.Now;
                    _designService.CreateNew(model);
                    _designService.CommitChanges();
                    AlertSuccess(InfoString.CREATE_SUCCESSFULL);
                }
                catch (Exception ex)
                {
                    Log(ex);
                    AlertError(InfoString.ERROR_SYSTEM);
                }

                return(RedirectToAction("Index", "Design", new { ParentCategoryId = model.ParentCategoryId }));
            }
            AlertWarning(InfoString.INVALID_INFO);
            ViewData["ParentCategories"] = _categoryService.GetParents(1);//parent type production
            return(View(model));
        }