public ActionResult CreateSlide()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageContentSlider))
                return AccessDeniedView();

            ViewBag.AllLanguages = _languageService.GetAllLanguages(true);
            var model = new ContentSliderSlideModel();
            model.AvailableStores = _storeService.GetAllStores().Select(s => s.ToModel()).ToList();

            var lastSlide = _contentSliderSettings.Slides.OrderByDescending(x => x.DisplayOrder).FirstOrDefault();
            if (lastSlide != null)
                model.DisplayOrder = lastSlide.DisplayOrder + 1;

            return View(model);
        }
        public ActionResult CreateSlide(ContentSliderSlideModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageContentSlider))
                return AccessDeniedView();

            ViewBag.AllLanguages = _languageService.GetAllLanguages(true);

            if (ModelState.IsValid)
            {
                model.PictureUrl = _pictureService.GetPictureUrl(model.PictureId);
                model.LanguageName = _languageService.GetLanguageByCulture(model.LanguageCulture).Name;
                _contentSliderSettings.Slides.Add(model.ToEntity());
                MediaHelper.UpdatePictureTransientState(0, model.PictureId, true);
                _settingService.SaveSetting(_contentSliderSettings);

                NotifySuccess(_localizationService.GetResource("Admin.Configuration.ContentSlider.Slide.Added"));
                return RedirectToAction("Index");
            }

            return View(model);
        }
        public ActionResult EditSlide(ContentSliderSlideModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageContentSlider))
                return AccessDeniedView();

            if (model == null)
                //No slide found
                return RedirectToAction("Index");

            var index = Request.QueryString["index"].ToInt();

            if (ModelState.IsValid)
            {
                Language lang = null;
                int langId = model.LanguageCulture.ToInt();

                if (langId > 0)
                {
                    lang = _languageService.GetLanguageById(langId);
                }
                else
                {
                    lang = _languageService.GetLanguageByCulture(model.LanguageCulture);
                }

                if (lang != null)
                {
                    model.LanguageName = lang.Name;
                }

                model.PictureUrl = _pictureService.GetPictureUrl(model.PictureId);            

                //delete an old picture (if deleted or updated)
                int prevPictureId = _contentSliderSettings.Slides[index].PictureId;
                if (prevPictureId > 0 && prevPictureId != model.PictureId)
                {
                    var prevPicture = _pictureService.GetPictureById(prevPictureId);
                    if (prevPicture != null)
                        _pictureService.DeletePicture(prevPicture);
                }

                _contentSliderSettings.Slides[index] = model.ToEntity();
                _settingService.SaveSetting(_contentSliderSettings);

                NotifySuccess(_localizationService.GetResource("Admin.Configuration.ContentSlider.Slide.Updated"));

                return continueEditing ? RedirectToAction("EditSlide", new { index = index }) : RedirectToAction("Index");
            }

            return View(model);
        }