[HttpPost] //lkhi submit dữ liệu public ActionResult Input(Category model) { if (string.IsNullOrEmpty(model.CategoryName)) { ModelState.AddModelError("CategoryName", "Category Name required"); } if (string.IsNullOrEmpty(model.Description)) { model.Description = ""; } if (!ModelState.IsValid) { return(View(model)); } try { if (model.CategoryID == 0) { int supplierId = CatalogBLL.Categories_Add(model); return(RedirectToAction("Index")); } else { bool updateResult = CatalogBLL.Categories_Update(model); return(RedirectToAction("Index")); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message + ": " + ex.StackTrace); return(View()); } }