コード例 #1
0
        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());
        }
コード例 #2
0
        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));
        }
コード例 #3
0
 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());
 }
コード例 #4
0
 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());
 }
コード例 #5
0
        public ActionResult TwoRowCarousels()
        {
            var model = new JCarouselDao().GetJCarousels();

            return(PartialView(model));
        }
コード例 #6
0
        public ActionResult Edit(int Id)
        {
            var jCarousel = new JCarouselDao().GetJCarouselById(Id);

            return(View(jCarousel));
        }
コード例 #7
0
        // GET: Admin/JCarousels
        public ActionResult Index(int page = 1, int pageSize = 10)
        {
            var jCarousels = new JCarouselDao().GetJCarousels(page, pageSize);

            return(View(jCarousels));
        }
コード例 #8
0
        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 }));
            }
        }