Exemplo n.º 1
0
 public ActionResult Create(PHONG phong)
 {
     if (ModelState.IsValid)
     {
         var dao = new PhongModel();
         if (dao.Find(phong.MaPhong) != null)
         {
             SetAlert("Mã phòng này đã có trong hệ thống", "error");
             return(RedirectToAction("Create", "Phong"));
         }
         String result = dao.Insert(phong);
         if (!String.IsNullOrEmpty(result))
         {
             SetAlert("Thêm phòng thành công", "success");
             return(RedirectToAction("Index", "Phong"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm phòng không thành công");
         }
     }
     return(View());
 }