public async Task <IActionResult> OnGetAsync() { Employee = await userManager.GetUserAsync(User).ConfigureAwait(false); Role = await roleManager.FindByIdAsync(Employee.RoleId.ToString()).ConfigureAwait(false); if (!Role.CanAdministerSystem) { return(RedirectToPage("/Index")); } var task = string.IsNullOrWhiteSpace(Query) ? venues.FetchCountedVenues(PageNumber, 20) : venues.FetchCountedQueriedVenues(Query, PageNumber, 20); var results = (await task.ConfigureAwait(false)) .Ensure(e => e.HasValue, "Venues found") .OnSuccess(e => e.Value) .OnBoth(e => e.IsSuccess ? e.Value : new PaginatedResult <Venue> { Data = new List <Venue>(), Count = 0 }); TotalResults = results.Count; Venues = results.Data; Title = $"Venues ({TotalResults})"; HasNextPage = (PageNumber + 1) <= (TotalResults / 20); return(Page()); }