public async Task <IActionResult> Index([FromQuery] int page = 1, [FromQuery] int perPage = 10) { var paginatedBranches = await _branchService.GetPaginated(page, perPage); if (paginatedBranches.Results.Any()) { foreach (var branch in paginatedBranches.Results) { var branchId = branch.Id; branch.IsOpen = await _branchService.IsBranchOpen(branchId); branch.NumberOfAssets = await _branchService.GetAssetCount(branchId); branch.NumberOfPatrons = await _branchService.GetPatronCount(branchId); } var model = new BranchIndexModel { PageOfBranches = paginatedBranches }; return(View(model)); } var emptyModel = new BranchIndexModel { PageOfBranches = new PaginationResult <LibraryBranchDto> { Results = new List <LibraryBranchDto>(), PageNumber = page, PerPage = perPage } }; return(View(emptyModel)); }