public ActionResult Create(Slide model) { if (!ModelState.IsValid) { return(View()); } //upload file var uploadResult = UploadFile(Common.Constants.AdminImagesUrl); model.Content = uploadResult.Length == 0 ? "" : uploadResult[0]; model.CreatedAt = DateTime.Now; model.CreatedBy = User.Identity.GetUserId(); bool isSuccess = slideDAO.Insert(model); if (isSuccess) { Notification.Success("Đã thêm thành công slide mới", Session); } else { Notification.Error("Có lỗi xảy ra, vui lòng thử lại sau", Session); } return(RedirectToAction("Index")); }
public ActionResult Create(Slide model) { if (ModelState.IsValid) { var dao = new SlideDAO(); var id = dao.Insert(model); if (id > 0) { SetAlert("Thêm mới thành công", "success"); return(RedirectToAction("Index", "Slide")); } else { ModelState.AddModelError("", "Xảy ra lỗi trong quá trình thêm mới "); } } return(View()); }
public ActionResult Create(Slide slide) { if (ModelState.IsValid) { SlideDAO dao = new SlideDAO(); bool success = dao.Insert(slide); if (success) { SetAlert("Thêm slide thành công", "success"); return(RedirectToAction("Index", "Slide")); } else { SetAlert("Thêm slide thất bại", "warning"); ModelState.AddModelError("", "Thêm slide không thành công"); } } return(RedirectToAction("Index", "Slide")); }
public ActionResult Create(Slide menu) { if (ModelState.IsValid) { var DAO = new SlideDAO(); long id = DAO.Insert(menu); if (id > 0) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index", "Slide")); } else { SetAlert("Thêm thất bại", "error"); ModelState.AddModelError("", "Thêm thất bại"); } } return(View("Index")); }
public ActionResult ThemMoi(Slide entity) { if (ModelState.IsValid) { var dao = new SlideDAO(); long id = dao.Insert(entity); if (id > 0) { SetAlert("Thêm hình ảnh thành công", "success"); return(RedirectToAction("Index", "Slide")); } else { SetAlert("Thêm hình ảnh không thành công", "error"); return(RedirectToAction("ThemMoi", "Slide")); } } return(View("Index")); }