Issue/567 (#568)
* Correctly manage page count when Page size = 0 * make =>TODO: Need to change the api to support full list Manage to support full list when pagesize is unknow
This commit is contained in:
@@ -7,7 +7,11 @@ namespace Microsoft.eShopWeb.ApplicationCore.Specifications
|
||||
{
|
||||
public CatalogFilterPaginatedSpecification(int skip, int take, int? brandId, int? typeId)
|
||||
: base()
|
||||
{
|
||||
{
|
||||
if (take == 0)
|
||||
{
|
||||
take = int.MaxValue;
|
||||
}
|
||||
Query
|
||||
.Where(i => (!brandId.HasValue || i.CatalogBrandId == brandId) &&
|
||||
(!typeId.HasValue || i.CatalogTypeId == typeId))
|
||||
|
||||
@@ -84,9 +84,8 @@ namespace BlazorAdmin.Services
|
||||
_logger.LogInformation("Fetching catalog items from API.");
|
||||
|
||||
var brandListTask = _brandService.List();
|
||||
var typeListTask = _typeService.List();
|
||||
//TODO: Need to change the api to support full list
|
||||
var itemListTask = _httpService.HttpGet<PagedCatalogItemResponse>($"catalog-items?PageSize=100");
|
||||
var typeListTask = _typeService.List();
|
||||
var itemListTask = _httpService.HttpGet<PagedCatalogItemResponse>($"catalog-items");
|
||||
await Task.WhenAll(brandListTask, typeListTask, itemListTask);
|
||||
var brands = brandListTask.Result;
|
||||
var types = typeListTask.Result;
|
||||
|
||||
@@ -56,7 +56,15 @@ namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints
|
||||
{
|
||||
item.PictureUri = _uriComposer.ComposePicUri(item.PictureUri);
|
||||
}
|
||||
response.PageCount = int.Parse(Math.Ceiling((decimal)totalItems / request.PageSize).ToString());
|
||||
|
||||
if (request.PageSize > 0)
|
||||
{
|
||||
response.PageCount = int.Parse(Math.Ceiling((decimal)totalItems / request.PageSize).ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
response.PageCount = totalItems > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user