Fix wrong calculation of items per page in catalog controller (last page was showing always 10)

This commit is contained in:
dsanz 2017-03-03 11:10:39 +01:00
parent e5c0340de5
commit ce0e36bb82

View File

@ -26,7 +26,7 @@ namespace Microsoft.eShopWeb.Controllers
public async Task<IActionResult> Index(int? BrandFilterApplied, int? TypesFilterApplied, int? page) public async Task<IActionResult> Index(int? BrandFilterApplied, int? TypesFilterApplied, int? page)
{ {
var itemsPage = 10; var itemsPage = 10;
var catalog = await _catalogSvc.GetCatalogItems(page ?? 0, itemsPage, BrandFilterApplied, TypesFilterApplied); var catalog = await _catalogSvc.GetCatalogItems(page ?? 0, itemsPage, BrandFilterApplied, TypesFilterApplied);
var vm = new CatalogIndex() var vm = new CatalogIndex()
{ {
@ -38,7 +38,7 @@ namespace Microsoft.eShopWeb.Controllers
PaginationInfo = new PaginationInfo() PaginationInfo = new PaginationInfo()
{ {
ActualPage = page ?? 0, ActualPage = page ?? 0,
ItemsPerPage = (catalog.Count < itemsPage) ? catalog.Count : itemsPage, ItemsPerPage = catalog.Data.Count,
TotalItems = catalog.Count, TotalItems = catalog.Count,
TotalPages = int.Parse(Math.Ceiling(((decimal)catalog.Count / itemsPage)).ToString()) TotalPages = int.Parse(Math.Ceiling(((decimal)catalog.Count / itemsPage)).ToString())
} }