Inheritance: System.Web.UI.Page
        public int InsertJCarousels(JCarousel jCarousel)
        {
            if (jCarousel == null)
            {
                throw new ArgumentNullException(nameof(jCarousel));
            }

            dbContext.JCarousels.Add(jCarousel);
            dbContext.SaveChanges();
            return(jCarousel.Id);
        }
Beispiel #2
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());
 }
Beispiel #3
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());
 }
        public bool UpdateJCarousels(JCarousel entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            var jCarousel = dbContext.JCarousels.Find(entity.Id);

            if (jCarousel == null)
            {
                throw new ArgumentNullException(nameof(jCarousel));
            }
            jCarousel.Name                      = entity.Name;
            jCarousel.Title                     = entity.Title;
            jCarousel.DataSourceType            = entity.DataSourceType;
            jCarousel.CarouselType              = entity.CarouselType;
            jCarousel.JCarousel_Product_Mapping = entity.JCarousel_Product_Mapping;

            dbContext.SaveChanges();
            return(true);
        }