public async Task <ActionResult> Index(PagerParameters pagerParameters, AuditTrailOrderBy?orderBy = null) { if (!await _authorizationService.AuthorizeAsync(User, AuditTrailPermissions.ViewAuditTrail)) { return(Forbid()); } var siteSettings = await _siteService.GetSiteSettingsAsync(); var pager = new Pager(pagerParameters, siteSettings.PageSize); var filters = Filters.From(QueryHelpers.ParseQuery(Request.QueryString.Value), _updateModelAccessor.ModelUpdater); var searchResult = await _auditTrailManager.GetAuditTrailEventsAsync(pager.Page, pager.PageSize, filters, orderBy ?? AuditTrailOrderBy.DateDescending); if (!_updateModelAccessor.ModelUpdater.ModelState.IsValid) { searchResult.AuditTrailEvents = Enumerable.Empty <AuditTrailEvent>(); } var pagerShape = (await _shapeFactory.New.Pager(pager)).TotalItemCount(searchResult.TotalCount); var eventDescriptors = _auditTrailManager.DescribeCategories() .SelectMany(categoryDescriptor => categoryDescriptor.Events) .ToDictionary(eventDescriptor => eventDescriptor.FullEventName); var auditTrailEventsSummaryViewModel = searchResult.AuditTrailEvents.Select(auditTrailEvent => { var eventDescriptor = eventDescriptors.ContainsKey(auditTrailEvent.FullEventName) ? eventDescriptors[auditTrailEvent.FullEventName] : AuditTrailEventDescriptor.Basic(auditTrailEvent); return(new AuditTrailEventSummaryViewModel { AuditTrailEvent = auditTrailEvent, EventDescriptor = eventDescriptor, CategoryDescriptor = eventDescriptor.CategoryDescriptor, AdditionalColumnsShapes = _auditTrailEventDisplayManager.BuildAdditionalColumnsShapesAsync(auditTrailEvent), SummaryShape = _auditTrailEventDisplayManager.BuildDisplayAsync(auditTrailEvent, "SummaryAdmin"), ActionsShape = _auditTrailEventDisplayManager.BuildActionsAsync(auditTrailEvent, "SummaryAdmin") }); }); return(View(new AuditTrailViewModel { AuditTrailEvents = auditTrailEventsSummaryViewModel, AdditionalColumnNames = await _auditTrailEventDisplayManager.BuildAdditionalColumnNamesShapesAsync(), Pager = pagerShape, OrderBy = orderBy ?? AuditTrailOrderBy.DateDescending, FilterDisplay = await _auditTrailEventDisplayManager.BuildFilterDisplayAsync(filters) })); }