private ContentSliderSettingsModel PrepareContentSliderSettingsModel(ContentSliderSettingsModel modelIn = null)
		{
			int rowIndex = 0;
			var allStores = _storeService.GetAllStores();
			var model = _contentSliderSettings.ToModel();

			model.StoreCount = allStores.Count;

			model.AvailableStores.Add(new SelectListItem() { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" });
			foreach (var s in allStores)
			{
				model.AvailableStores.Add(new SelectListItem() { Text = s.Name, Value = s.Id.ToString() });
			}

			foreach (var slide in model.Slides)
			{
				slide.SlideIndex = rowIndex++;

				var language = _languageService.GetLanguageByCulture(slide.LanguageCulture);
				if (language != null)
				{
					slide.LanguageName = language.Name;
				}
				else
				{
					var seoCode = _languageService.GetDefaultLanguageSeoCode();
					slide.LanguageName = _languageService.GetLanguageBySeoCode(seoCode).Name;
				}
			}

			// note order: first SlideIndex then search filter.
			if (modelIn != null && modelIn.SearchStoreId > 0)
			{
				model.Slides = model.Slides
					.Where(x => x.LimitedToStores && x.SelectedStoreIds != null && x.SelectedStoreIds.Contains(modelIn.SearchStoreId))
					.ToList();
			}

			return model;
		}
        public ActionResult Index(ContentSliderSettingsModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageContentSlider))
                return AccessDeniedView();

            _contentSliderSettings.IsActive = model.IsActive;
            _contentSliderSettings.ContentSliderHeight = model.ContentSliderHeight;
            _contentSliderSettings.BackgroundPictureId = model.BackgroundPictureId;
            _contentSliderSettings.BackgroundPictureUrl = _pictureService.GetPictureUrl(model.BackgroundPictureId);
            _contentSliderSettings.AutoPlay = model.AutoPlay;
            _contentSliderSettings.AutoPlayDelay = model.AutoPlayDelay;

            _settingService.SaveSetting(_contentSliderSettings);

			var viewModel = PrepareContentSliderSettingsModel(model);

            return View(viewModel);
        }
		public ActionResult SlideList(GridCommand command, ContentSliderSettingsModel model)
		{
			var gridModel = new GridModel();
			var viewModel = PrepareContentSliderSettingsModel(model);

			gridModel.Data = viewModel.Slides.OrderBy(s => s.LanguageName).ThenBy(s => s.DisplayOrder);

            return new JsonResult { Data = gridModel };
		}