public ActionResult Index(PagerParameters pagerParameters, AuditTrailOrderBy?orderBy = null) { if (!_authorizer.Authorize(Permissions.ViewAuditTrail)) { return(new HttpUnauthorizedResult()); } var pager = new Pager(_services.WorkContext.CurrentSite, pagerParameters); var filters = Filters.From(Request.QueryString, this); var pageOfData = _auditTrailManager.GetRecords(pager.Page, pager.PageSize, filters, orderBy ?? AuditTrailOrderBy.DateDescending); // If there's a filter validation error, clear the results. if (!ModelState.IsValid) { pageOfData = new PageOfItems <AuditTrailEventRecord>(Enumerable.Empty <AuditTrailEventRecord>()); } var pagerShape = New.Pager(pager).TotalItemCount(pageOfData.TotalItemCount); var filterDisplay = _auditTrailManager.BuildFilterDisplay(filters); var eventDescriptorsQuery = from c in _auditTrailManager.DescribeCategories() from e in c.Events select e; var eventDescriptors = eventDescriptorsQuery.ToDictionary(x => x.Event); var recordViewModelsQuery = from record in pageOfData let descriptor = eventDescriptors.ContainsKey(record.FullEventName) ? eventDescriptors[record.FullEventName] : AuditTrailEventDescriptor.Basic(record) select new AuditTrailEventSummaryViewModel { Record = record, EventDescriptor = descriptor, CategoryDescriptor = descriptor.CategoryDescriptor, SummaryShape = _displayBuilder.BuildDisplay(record, "SummaryAdmin"), ActionsShape = _displayBuilder.BuildActions(record, "SummaryAdmin"), }; var viewModel = new AuditTrailViewModel { Records = recordViewModelsQuery.ToArray(), Pager = pagerShape, OrderBy = orderBy ?? AuditTrailOrderBy.DateDescending, FilterDisplay = filterDisplay }; return(View(viewModel)); }