Example #1
0
        public IActionResult PostFormCarousel(CarouselModel carouselModel)
        {
            var lastImages = imageManager.Get().Reverse().Take(2).ToList();

            try
            {
                Carousel entity = carouselManager.Get().Where(e => e.Id == carouselModel.num).FirstOrDefault();
                entity.Image_Id = lastImages[1].Id;
                entity.Title    = carouselModel.title;
                entity.Text     = carouselModel.text;
                entity.ImageMin = lastImages[0].ImagePath;
                carouselManager.Update(entity);
            }
            catch (Exception ex)
            {
                Carousel carousel = new Carousel()
                {
                    Image_Id = lastImages[1].Id,
                    Text     = carouselModel.text
                };
                carouselManager.Insert(carousel);
            }

            return(RedirectToAction("Carousel"));
        }
Example #2
0
        public IActionResult ShowCarousel(int id)
        {
            var slider = carouselManager.Get().Where(e => e.Id == id).FirstOrDefault();
            var image  = imageManager.Get().Where(e => e.Id == slider.Image_Id).FirstOrDefault();

            return(View(new CarouselViewModel()
            {
                Image = image,
                Carousel = slider
            }));
        }