8.1.4 Correcting the Page Count; Listing 8-11 Creating the Category-Aware Pagination Data in the ProductController.cs File

chap08
Jason Zhu 2021-09-08 23:43:01 +10:00
parent 59e5f471db
commit 8f39a1ae1c
1 changed files with 3 additions and 1 deletions

View File

@ -32,7 +32,9 @@ namespace SportsStore.WebUI.Controllers
{
CurrentPage = page,
ItemsPerPage = PageSize,
TotalItems = repository.Products.Count()
TotalItems = category == null ?
repository.Products.Count() :
repository.Products.Where(e => e.Category == category).Count()
},
CurrentCategory = category
};