[HttpPost] //lkhi submit dữ liệu public ActionResult Input(Customer model, string type = "") { ViewBag.ListCountry = CatalogBLL.Country_List(); if (string.IsNullOrEmpty(model.CompanyName)) { model.Address = ""; } if (string.IsNullOrEmpty(model.Address)) { model.Address = ""; } if (string.IsNullOrEmpty(model.City)) { model.City = ""; } if (string.IsNullOrEmpty(model.Address)) { model.Address = ""; } if (string.IsNullOrEmpty(model.ContactName)) { model.ContactName = ""; } if (string.IsNullOrEmpty(model.Country)) { model.Country = ""; } if (string.IsNullOrEmpty(model.Fax)) { model.Fax = ""; } if (string.IsNullOrEmpty(model.Phone)) { model.Phone = ""; } if (!ModelState.IsValid) { return(View(model)); } try { if (type == "Add") { int supplierId = CatalogBLL.Customers_Add(model); return(RedirectToAction("Index")); } else { bool updateResult = CatalogBLL.Customers_Update(model); return(RedirectToAction("Index")); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message + ": " + ex.StackTrace); return(View()); } }