public virtual IActionResult WidgetZoneSlideList(WidgetZoneSlideSearchModel searchModel) { //return access denied result if customer has no permissions if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets)) { return(AccessDeniedDataTablesJson()); } var gridModel = _widgetZoneSlideModelFactory.PrepareSlidePagedListModel(searchModel); return(Json(gridModel)); }
/// <summary> /// Prepare widget zone slide list model /// </summary> /// <param name="searchModel">Widget zone slide search model</param> /// <returns>Widget zone slides paged list</returns> public virtual WidgetZoneSlideSearchModel.SlideList PrepareSlidePagedListModel(WidgetZoneSlideSearchModel searchModel) { var slides = _widgetZoneSlideService.GetWidgetZoneSlides(searchModel.WidgetZoneId, null, searchModel.Page - 1, searchModel.PageSize); var gridModel = new WidgetZoneSlideSearchModel.SlideList().PrepareToGrid(searchModel, slides, () => { return(slides.Select(widgetZoneSlide => { var slide = _slideService.GetSlideById(widgetZoneSlide.SlideId); var picture = _pictureService.GetPictureById(slide.PictureId.GetValueOrDefault(0)); var pictureUrl = _pictureService.GetPictureUrl(picture.Id, 300); return new WidgetZoneSlideSearchModel.SlideListItem() { Id = widgetZoneSlide.Id, PictureUrl = pictureUrl, StartDateUtc = slide.StartDateUtc, EndDateUtc = slide.EndDateUtc, Published = slide.Published, DisplayOrder = widgetZoneSlide.DisplayOrder }; }).OrderBy(x => x.DisplayOrder)); }); return(gridModel); }