protected virtual async Task SaveSliderItemAclAsync(SliderItem sliderItem, SwiperSliderItemModel model) { sliderItem.SubjectToAcl = model.SelectedCustomerRoleIds.Any(); await _swiperSliderService.UpdateSliderItemAsync(sliderItem); await SaveAclAsync(sliderItem, model); }
public virtual async Task <IActionResult> SliderItemCreate(SwiperSliderItemModel model, bool continueEditing) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageWidgets)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var sliderItem = model.ToEntity <SliderItem>(); await _swiperSliderService.InsertSliderItemAsync(sliderItem); await SaveSliderItemAclAsync(sliderItem, model); await SaveSliderItemStoreMappingsAsync(sliderItem, model); if (sliderItem.Id > 0) { //activity log await _customerActivityService.InsertActivityAsync("AddNewSwiperSliderItem", string.Format(await _localizationService.GetResourceAsync("Nop.Plugin.Widgets.SwiperSlider.Admin.ActivityLog.AddNewSwiperSliderItem"), sliderItem.Name), sliderItem); var message = await _localizationService.GetResourceAsync("Nop.Plugin.Widgets.SwiperSlider.Admin.Notifications.SliderItems.Added"); _notificationService.SuccessNotification(string.Format(message, sliderItem.Name)); if (continueEditing) { return(RedirectToAction("SliderItemEdit", new { id = sliderItem.Id, sliderId = sliderItem.SliderId })); } } else { _notificationService.ErrorNotification(await _localizationService.GetResourceAsync("Nop.Plugin.Widgets.SwiperSlider.Admin.Notifications.SliderItems.NotAdded")); } //select an appropriate card SaveSelectedCardName("swiper-slider-items"); return(RedirectToAction("Edit", new { id = model.SliderId })); } model = await _swiperSliderModelFactory.PrepareSliderItemModelAsync(model, null); return(View(model)); }
public virtual async Task <SwiperSliderItemModel> PrepareSliderItemModelAsync(SwiperSliderItemModel model, SliderItem sliderItem) { if (sliderItem != null) { if (model == null) { model = sliderItem.ToModel <SwiperSliderItemModel>(); } var slider = await _swiperSliderService.GetSliderByIdAsync(sliderId : sliderItem.SliderId); model.SliderName = slider.Name; var picture = await _pictureService.GetPictureByIdAsync(sliderItem.PictureId); (model.PictureThumbnailUrl, _) = await _pictureService.GetPictureUrlAsync(picture, 120); } if (sliderItem == null) { model.Published = true; } //prepare model customer roles await _aclSupportedModelFactory.PrepareModelCustomerRolesAsync(model, sliderItem, false); //prepare model stores await _storeMappingSupportedModelFactory.PrepareModelStoresAsync(model, sliderItem, false); return(model); }
protected virtual async Task SaveSliderItemStoreMappingsAsync(SliderItem sliderItem, SwiperSliderItemModel model) { sliderItem.LimitedToStores = model.SelectedStoreIds.Any(); await _swiperSliderService.UpdateSliderItemAsync(sliderItem); await SaveStoreMappingsAsync(sliderItem, model); }