コード例 #1
0
 public ActionResult Input(Shipper model)
 {
     try
     {
         if (string.IsNullOrEmpty(model.CompanyName))
         {
             ModelState.AddModelError("CompanyName", "CompanyName expected");
         }
         if (string.IsNullOrEmpty(model.Phone))
         {
             model.Phone = "";
         }
         if (!ModelState.IsValid)
         {
             ViewBag.Title = model.ShipperID == 0 ? "Create new Shipper" : "Edit a Shipper";
             return(View(model));
         }
         if (model.ShipperID == 0)
         {
             CataLogBLL.AddShipper(model);
         }
         else
         {
             CataLogBLL.UpdateShipper(model);
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("Loi", ex.StackTrace);
         return(View(model));
     }
 }