public ActionResult Edit(LoaiSach collection)
 {
     try
     {
         if (ModelState.IsValid)
         {
             // TODO: Add insert logic here
             var dao    = new LoaiSachDao();
             var result = dao.Update(collection);
             if (result)
             {
                 SetAlert("Sửa thành công", "success");
                 return(RedirectToAction("Index", "LoaiSach"));
             }
             else
             {
                 ModelState.AddModelError("", "Cập nhật sản phẩm không thành công");
             }
         }
         return(View(collection));
     }
     catch
     {
         return(View("Index"));
     }
 }
 public ActionResult Create(LoaiSach collection)
 {
     try
     {
         if (ModelState.IsValid)
         {
             // TODO: Add insert logic here
             var  dao = new LoaiSachDao();
             long id  = dao.Insert(collection);
             if (id > 0)
             {
                 SetAlert("Thêm thành công", "success");
                 return(RedirectToAction("Index", "LoaiSach"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm sản phẩm không thành công");
             }
         }
         return(View(collection));
     }
     catch
     {
         return(View("Index"));
     }
 }
Exemple #3
0
        // GET: Admin/Sach/Create
        public ActionResult Create()
        {
            LoaiSachDao lsp1 = new LoaiSachDao();
            var         lSp1 = lsp1.ListOf();

            ViewBag.LSP = lSp1;
            return(View());
        }
        // GET: Admin/LoaiSach
        //public ActionResult Index()
        //{
        //    var ls1 = new LoaiSachModel();
        //    var ls2 = ls1.ListAll();
        //    return View(ls2);
        //}



        public ActionResult Index(string searchString, int page = 1, int pagesize = 5)
        {
            //var iplCate = new SachModel();
            //var model = iplCate.ListAll();
            var dao   = new LoaiSachDao();
            var model = dao.ListAllPaging(searchString, page, pagesize);

            ViewBag.SearchString = searchString;
            return(View(model));
        }
Exemple #5
0
        public ActionResult Edit(int id)
        {
            LoaiSachDao lsp = new LoaiSachDao();
            var         lSp = lsp.ListOf();



            ViewBag.LSP = lSp;

            SachDao dao = new SachDao();
            var     sp  = dao.Detail(id);

            return(View(sp));
        }
        public ActionResult Edit(int id)
        {
            var Loaisach = new LoaiSachDao().ViewDetails(id);

            return(View(Loaisach));
        }