Browse Source
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
main
Cédric Michel
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
16 additions and
5 deletions
src/ApplicationCore/Specifications/CatalogFilterPaginatedSpecification.cs
src/BlazorAdmin/Services/CatalogItemService.cs
src/PublicApi/CatalogItemEndpoints/ListPaged.cs
@ -8,6 +8,10 @@ namespace Microsoft.eShopWeb.ApplicationCore.Specifications
public CatalogFilterPaginatedSpecification ( int skip , int take , int? brandId , int? typeId )
public CatalogFilterPaginatedSpecification ( int skip , int take , int? brandId , int? typeId )
: base ( )
: base ( )
{
{
if ( take = = 0 )
{
take = int . MaxValue ;
}
Query
Query
. Where ( i = > ( ! brandId . HasValue | | i . CatalogBrandId = = brandId ) & &
. Where ( i = > ( ! brandId . HasValue | | i . CatalogBrandId = = brandId ) & &
( ! typeId . HasValue | | i . CatalogTypeId = = typeId ) )
( ! typeId . HasValue | | i . CatalogTypeId = = typeId ) )
@ -85,8 +85,7 @@ namespace BlazorAdmin.Services
var brandListTask = _ brandService . List ( ) ;
var brandListTask = _ brandService . List ( ) ;
var typeListTask = _ typeService . List ( ) ;
var typeListTask = _ typeService . List ( ) ;
//TODO: Need to change the api to support full list
var itemListTask = _ httpService . HttpGet < PagedCatalogItemResponse > ( $"catalog-items" ) ;
var itemListTask = _ httpService . HttpGet < PagedCatalogItemResponse > ( $"catalog-items?PageSize=100" ) ;
await Task . WhenAll ( brandListTask , typeListTask , itemListTask ) ;
await Task . WhenAll ( brandListTask , typeListTask , itemListTask ) ;
var brands = brandListTask . Result ;
var brands = brandListTask . Result ;
var types = typeListTask . Result ;
var types = typeListTask . Result ;
@ -56,7 +56,15 @@ namespace Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints
{
{
item . PictureUri = _ uriComposer . ComposePicUri ( item . PictureUri ) ;
item . PictureUri = _ uriComposer . ComposePicUri ( item . PictureUri ) ;
}
}
if ( request . PageSize > 0 )
{
response . PageCount = int . Parse ( Math . Ceiling ( ( decimal ) totalItems / request . PageSize ) . ToString ( ) ) ;
response . PageCount = int . Parse ( Math . Ceiling ( ( decimal ) totalItems / request . PageSize ) . ToString ( ) ) ;
}
else
{
response . PageCount = totalItems > 0 ? 1 : 0 ;
}
return Ok ( response ) ;
return Ok ( response ) ;
}
}