예제 #1
0
 public ActionResult Add(TacGia tacgia)
 {
     if (Session["User"] == null)
     {
         return(RedirectToAction("Login", "Login"));
     }
     else
     {
         var model = new TacGiaDao().CheckTacGia(tacgia.TenTacGia, tacgia.Email);
         if (model == false)
         {
             ModelState.AddModelError("", "Tác Giả Này Đã Tồn Tại");
             return(View("Add"));
         }
         else
         {
             if (ModelState.IsValid)
             {
                 var dao = new TacGiaDao();
                 int id  = dao.Insert(tacgia);
                 if (id > 0)
                 {
                     return(RedirectToAction("Index", "TacGiaAD"));
                 }
                 else
                 {
                     ModelState.AddModelError("", "Thêm Mới Thất Bại");
                     return(View("Add"));
                 }
             }
         }
         return(View("Index"));
     }
 }
예제 #2
0
 public int Insert(TacGia obj)
 {
     return(dao.Insert(obj));
 }