public SearchableGridViewModel <WidgetUsageViewModel> Execute(GetWidgetUsagesCommandRequest request) { int pagesTotalCount; var pages = GetPages(request, out pagesTotalCount); var pageUsages = pages.Select(p => new WidgetUsageViewModel { Title = p.Title, Url = p.Url, Id = p.Id, Version = p.Version, Type = p.IsMasterPage ? WidgetUsageType.MasterPage : WidgetUsageType.Page }); int widgetsTotalCount; var widgets = GetWidgets(request, out widgetsTotalCount); var widgetUsages = widgets.Select(p => new WidgetUsageViewModel { Title = p.WidgetName, Id = p.Id, Version = p.Version, Type = WidgetUsageType.HtmlWidget }); var items = pageUsages.Concat(widgetUsages).AsQueryable(); items = (request.Options.Direction == SortDirection.Descending) ? items.OrderByDescending(i => i.Title) : items.OrderBy(i => i.Title); items = items.AddPaging(request.Options); return(new SearchableGridViewModel <WidgetUsageViewModel>(items, request.Options, pagesTotalCount + widgetsTotalCount)); }
private List <SiteSettingWidgetItemViewModel> GetWidgets(GetWidgetUsagesCommandRequest request, out int totalCount) { var filter = new WidgetsFilter(); filter.CopyFrom(request.Options); filter.PageSize = filter.PageNumber * filter.PageSize; filter.PageNumber = 1; filter.Column = null; filter.ChildContentId = request.WidgetId; var widgets = widgetService.GetFilteredWidgetsList(filter); totalCount = widgets.TotalCount; return(widgets.Items.ToList()); }
private List <SiteSettingPageViewModel> GetPages(GetWidgetUsagesCommandRequest request, out int totalCount) { var filter = new PagesFilter(); filter.CopyFrom(request.Options); filter.PageSize = filter.PageNumber * filter.PageSize; filter.PageNumber = 1; filter.ContentId = request.WidgetId; filter.Column = null; filter.IncludeArchived = true; filter.IncludeMasterPages = true; var pages = pageListService.GetFilteredPagesList(filter); totalCount = pages.TotalCount; return(pages.Items.ToList()); }
public ActionResult WidgetUsages(string widgetId, SearchableGridOptions options) { options.SetDefaultPaging(); var request = new GetWidgetUsagesCommandRequest { Options = options, WidgetId = widgetId.ToGuidOrDefault() }; var model = GetCommand<GetWidgetUsagesCommand>().ExecuteCommand(request); var view = RenderView("Partial/WidgetUsagesTemplate", null); return ComboWireJson(model != null, view, model, JsonRequestBehavior.AllowGet); }