public ActionResult Index(Core.Contents.ViewModels.ListContentsViewModel model, PagerParameters pagerParameters) { var query = _containerService.GetContainersQuery(VersionOptions.Latest); if (!String.IsNullOrEmpty(model.TypeName)) { var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(model.TypeName); if (contentTypeDefinition == null) { return(HttpNotFound()); } model.TypeDisplayName = !String.IsNullOrWhiteSpace(contentTypeDefinition.DisplayName) ? contentTypeDefinition.DisplayName : contentTypeDefinition.Name; query = query.ForType(model.TypeName); } switch (model.Options.OrderBy) { case ContentsOrder.Modified: query = query.OrderByDescending <CommonPartRecord>(cr => cr.ModifiedUtc); break; case ContentsOrder.Published: query = query.OrderByDescending <CommonPartRecord>(cr => cr.PublishedUtc); break; case ContentsOrder.Created: query = query.OrderByDescending <CommonPartRecord>(cr => cr.CreatedUtc); break; } model.Options.SelectedFilter = model.TypeName; model.Options.FilterOptions = _containerService.GetContainerTypes() .Select(ctd => new KeyValuePair <string, string>(ctd.Name, ctd.DisplayName)) .ToList().OrderBy(kvp => kvp.Value); var pager = new Pager(_services.WorkContext.CurrentSite, pagerParameters); var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count()); var pageOfLists = query.Slice(pager.GetStartIndex(), pager.PageSize); var listsShape = Shape.List(); listsShape.AddRange(pageOfLists.Select(x => _contentManager.BuildDisplay(x, "SummaryAdmin")).ToList()); var viewModel = Shape.ViewModel() .Lists(listsShape) .Pager(pagerShape) .Options(model.Options); return(View(viewModel)); }