public ActionResult OnCreate(ProductBrandModels brand) { if (ModelState.IsValid) { brand.ImageUrl = brand.Image != null? brand.Image.Upload() : brand.ImageUrl; var result = ProductBrandService.Insert ( brand.Name, brand.CategoryId, brand.ImageUrl, brand.Status ); if (result == Result.Exists) { ModelState.AddModelError("", $"Tên thương hiệu '{brand.Name}' đã tồn tại trên hệ thống."); ViewBag.ListState = DataHelper.ListEnumType <StateEnum>(); ViewBag.ListCategory = GetListMutilCategoryItem(); return(View("Create", brand)); } SetFlashMessage($"Thêm thương hiệu '{brand.Name}' thành công."); if (brand.SaveList) { return(RedirectToAction("Index")); } ViewBag.ListState = DataHelper.ListEnumType <StateEnum>(); ViewBag.ListCategory = GetListMutilCategoryItem(); ModelState.Clear(); return(View("Create", brand.ResetValue())); } ViewBag.ListState = DataHelper.ListEnumType <StateEnum>(); ViewBag.ListCategory = GetListMutilCategoryItem(); return(View("Create", brand)); }