From 8f39a1ae1cf9e31111ec0df8cca77cb4e0d7bc86 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Wed, 8 Sep 2021 23:43:01 +1000 Subject: [PATCH] 8.1.4 Correcting the Page Count; Listing 8-11 Creating the Category-Aware Pagination Data in the ProductController.cs File --- .../SportsStore.WebUI/Controllers/ProductController.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SportsStore/SportsStore.WebUI/Controllers/ProductController.cs b/SportsStore/SportsStore.WebUI/Controllers/ProductController.cs index 350ea92..b3ed5fa 100644 --- a/SportsStore/SportsStore.WebUI/Controllers/ProductController.cs +++ b/SportsStore/SportsStore.WebUI/Controllers/ProductController.cs @@ -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 };