public ActionResult Edit(Sach sach)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            else
            {
                ViewBag.MaChuDe = new SelectList(db.ChuDes.OrderBy(n => n.TenChuDe), "MaChuDe", "TenChuDe", sach.MaChuDe);
                ViewBag.MaNXB   = new SelectList(db.NhaXuatBans.OrderBy(n => n.MaNXB), "MaNXB", "TenNXB", sach.MaNXB);
                var model = new SachDao().CheckSach(sach.TenSach);

                if (ModelState.IsValid)
                {
                    var dao = new SachDao();

                    var result = dao.Update(sach);
                    if (result)
                    {
                        return(RedirectToAction("Index", "SachAD"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Cập Nhật Sach Thất Bại");
                        return(View("Edit"));
                    }

                    //}
                }
                return(View("Index"));
            }
        }
Exemplo n.º 2
0
 public ActionResult Edit(Sach collection)
 {
     try
     {
         if (ModelState.IsValid)
         {
             // TODO: Add insert logic here
             var dao    = new SachDao();
             var result = dao.Update(collection);
             if (result)
             {
                 SetAlert("Sửa thành công", "success");
                 return(RedirectToAction("Index", "Sach"));
             }
             else
             {
                 ModelState.AddModelError("", "Cập nhật sản phẩm không thành công");
             }
         }
         return(View(collection));
     }
     catch
     {
         return(View("Index"));
     }
 }
Exemplo n.º 3
0
 public int Update(Sach obj)
 {
     return(dao.Update(obj));
 }