public bool FuncUpdate(Slide model, string fileName, SlideDao dao)
        {
            model.Image = "/Assets/client/images/" + fileName;
            bool result = dao.Update(model);

            if (result)
            {
                TempData["Success"] = "Cập nhật slide thành công!";
                return(true);
            }
            else
            {
                TempData["Error"] = "Cập nhật slide thất bại!";
                return(false);
            }
        }
示例#2
0
 public ActionResult Edit([Bind(Include = "ID,Image, Link, CreateDate, Status")] Slide slide, HttpPostedFileBase image)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var path     = "";
             var filename = "";
             var dao      = new SlideDao();
             if (image != null)
             {
                 filename = DateTime.Now.ToString("dd-MM-yy-hh-mm-ss-") + image.FileName;
                 path     = Path.Combine(Server.MapPath("~/Image"), filename);
                 image.SaveAs(path);
                 slide.Image = filename;
             }
             //else
             //{
             //    content.Image = "~/Image/logo.png";
             //}
             slide.Link   = slide.Link;
             slide.Status = Convert.ToBoolean(true);
             var result = dao.Update(slide);
             if (result)
             {
                 SetAlert("Sửa thành công", "success");
                 ViewBag.Success = "Cập nhật thành công";
                 slide           = new Slide();
                 return(RedirectToAction("Index", "Product"));
             }
             else
             {
                 ModelState.AddModelError("", "Cập nhật ko thành công");
             }
         }
     }
     catch (DbEntityValidationException e)
     {
         throw e;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(View(slide));
 }
示例#3
0
 public ActionResult Edit(Slide xb)
 {
     if (ModelState.IsValid)
     {
         var dao    = new SlideDao();
         var result = dao.Update(xb);
         if (result)
         {
             SetAlert("Sửa thông tin slide thành công!", "success");
             return(RedirectToAction("Index", "Slide"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật slide không thành công!");
         }
     }
     return(View("Index"));
 }
示例#4
0
 public ActionResult Edit(Slide model)
 {
     if (ModelState.IsValid)
     {
         var session = (UserLogin)Session[CommonConstants.USER_SESSION];
         model.ModifiedBy = session.UserName;
         var dao    = new SlideDao();
         var result = dao.Update(model);
         if (result)
         {
             SetAlert("Update slide thành công", "success");
             return(RedirectToAction("Index", "Slide"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật slide không thành công");
         }
     }
     return(View());
 }
        public ActionResult Edit(Slide product)
        {
            var dao   = new SlideDao();
            var model = dao.ListAllForAdmin();

            if (ModelState.IsValid)
            {
                var result = dao.Update(product);

                if (result)
                {
                    return(RedirectToAction("Index", "Slide", model));
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật không thành công");
                    SetAlert("Cập nhật không thành công", "error");
                }
            }
            return(View("Edit"));
        }
示例#6
0
 public ActionResult Edit(SlideViewModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var slide = new Slide();
             slide.UpdateSlide(model);
             var result = _slideDao.Update(slide);
             if (result)
             {
                 SetAlert("Cập nhật thành công", "success");
                 return(RedirectToAction("Index", "Slide"));
             }
             else
             {
                 ModelState.AddModelError("", "Cập nhật thất bại");
             }
         }
         return(View(model));
     }
     catch
     { return(View()); }
 }