public ActionResult Delete(int Id) { var jCarouselDao = new JCarouselDao(); var result = jCarouselDao.DeleteJCarousels(Id); if (result) { SetNotification("Xoá JCarousels thành công ", "success"); return(RedirectToAction("Index", "JCarousels")); } else { ModelState.AddModelError("", "Xoá JCarousels không thành công"); } return(View()); }
public ActionResult ProductList(int jCarouselId) { if (jCarouselId == 0) { throw new ArgumentNullException(nameof(jCarouselId)); } var jCarousel = new JCarouselDao().GetJCarouselById(jCarouselId); if (jCarousel == null) { throw new ArgumentNullException(nameof(jCarousel)); } return(PartialView("_ProductList", jCarousel)); }
public ActionResult Edit(JCarousel jCarousel) { if (ModelState.IsValid) { var jCarouselDao = new JCarouselDao(); var result = jCarouselDao.UpdateJCarousels(jCarousel); if (result) { SetNotification("Cập nhật JCarousels thành công ", "success"); return(RedirectToAction("Index", "JCarousels")); } else { ModelState.AddModelError("", "Cập nhật JCarousels không thành công"); } } return(View()); }
public ActionResult Create(JCarousel jCarousel) { if (ModelState.IsValid) { var jCarouselDao = new JCarouselDao(); int Id = jCarouselDao.InsertJCarousels(jCarousel); if (Id > 0) { SetNotification("Thêm mới JCarousels thành công ", "success"); return(RedirectToAction("Index", "JCrousels")); } else { ModelState.AddModelError("", "Cập nhật JCrousels không thành công"); } } return(View()); }
public ActionResult TwoRowCarousels() { var model = new JCarouselDao().GetJCarousels(); return(PartialView(model)); }
public ActionResult Edit(int Id) { var jCarousel = new JCarouselDao().GetJCarouselById(Id); return(View(jCarousel)); }
// GET: Admin/JCarousels public ActionResult Index(int page = 1, int pageSize = 10) { var jCarousels = new JCarouselDao().GetJCarousels(page, pageSize); return(View(jCarousels)); }
public ActionResult ProductAddJCarouselPopup(int jCarouselId, List <int> selectedIds) { List <JCarousel_Product_Mapping> jCarousels = new List <JCarousel_Product_Mapping>(); if (jCarouselId == 0) { throw new ArgumentException(nameof(jCarouselId)); } var jCarousel = new JCarouselDao().GetJCarouselById(jCarouselId); if (jCarousel == null) { throw new ArgumentNullException(nameof(jCarousel)); } List <JCarousel_Product_Mapping> jCarouselCheck = new List <JCarousel_Product_Mapping>(); if (jCarousel.JCarousel_Product_Mapping.Count > 0) { foreach (var Id in selectedIds) { jCarouselCheck = jCarousel.JCarousel_Product_Mapping.Where(x => x.ProductId == Id).ToList(); if (jCarouselCheck.Count == 0) { var product = new JCarousel_Product_Mapping { ProductId = Id, JCarouselId = jCarouselId, DisplayOrder = Id }; jCarousels.Add(product); } } } else { foreach (var Id in selectedIds) { var product = new JCarousel_Product_Mapping { ProductId = Id, JCarouselId = jCarouselId, DisplayOrder = Id }; jCarousels.Add(product); } } if (jCarousels.Count > 0) { foreach (JCarousel_Product_Mapping item in jCarousels) { jCarousel.JCarousel_Product_Mapping.Add(item); } } var result = new JCarouselDao().UpdateJCarousels(jCarousel); if (result) { return(Json(new { Result = true })); } else { return(Json(new { Result = false })); } }