示例#1
0
 public ActionResult Input(Country model)
 {
     try
     {
         //TODO :Kiểm tra tính hợp lệ của dữ liệu nhập vào
         if (string.IsNullOrEmpty(model.CountryName))
         {
             ModelState.AddModelError("CountryName", "CountryName expected");
         }
         if (string.IsNullOrEmpty(model.Abbreviation))
         {
             model.Abbreviation = "";
         }
         //TODO :Lưu dữ liệu nhập vào
         if (model.CountryID == 0)
         {
             CountryBLL.AddCountry(model);
         }
         else
         {
             CountryBLL.UpdateCountry(model);
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message + ":" + ex.StackTrace);
         return(View(model));
     }
 }
        public ActionResult Edit(Country objCountry)
        {
            if (ModelState.IsValid)
            {
                CountryBLL objCountryBLL = new CountryBLL();

                objCountryBLL.UpdateCountry(objCountry);
            }
            return(RedirectToAction("Index", "Country"));
        }