From 0681fca95feab7b9c27b74fa3459922508b5210d Mon Sep 17 00:00:00 2001 From: akema-trebla Date: Tue, 28 Sep 2021 07:57:36 +0000 Subject: [PATCH 1/2] Int.MaxValue as default PageSize --- .../Persistence/Repositories/RepositoryAsync.cs | 2 +- src/Shared/Shared.DTOs/Filters/PaginationFilter.cs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Infrastructure/Persistence/Repositories/RepositoryAsync.cs b/src/Infrastructure/Persistence/Repositories/RepositoryAsync.cs index 2cfaf1f6df..8ed1725446 100644 --- a/src/Infrastructure/Persistence/Repositories/RepositoryAsync.cs +++ b/src/Infrastructure/Persistence/Repositories/RepositoryAsync.cs @@ -97,7 +97,7 @@ public async Task GetByIdAsync(Guid entityId, BaseSpecification> GetPaginatedListAsync(int pageNumber, int pageSize, string[] orderBy = null, Search search = null, Expression> expression = null, CancellationToken cancellationToken = default) + public async Task> GetPaginatedListAsync(int pageNumber, int pageSize = int.MaxValue, string[] orderBy = null, Search search = null, Expression> expression = null, CancellationToken cancellationToken = default) where T : BaseEntity where TDto : IDto { diff --git a/src/Shared/Shared.DTOs/Filters/PaginationFilter.cs b/src/Shared/Shared.DTOs/Filters/PaginationFilter.cs index f81b587721..f9290e85f6 100644 --- a/src/Shared/Shared.DTOs/Filters/PaginationFilter.cs +++ b/src/Shared/Shared.DTOs/Filters/PaginationFilter.cs @@ -2,6 +2,11 @@ namespace DN.WebApi.Shared.DTOs.Filters { public abstract class PaginationFilter : BaseFilter { + public PaginationFilter() + { + PageSize = int.MaxValue; + } + public int PageNumber { get; set; } public int PageSize { get; set; } From 5beb763c7d95a0dc08c4b24656e6da0a9deb41dc Mon Sep 17 00:00:00 2001 From: akema-trebla Date: Tue, 28 Sep 2021 08:04:07 +0000 Subject: [PATCH 2/2] Added FromQuery attribute so GET works on Swagger --- src/Bootstrapper/Controllers/v1/BrandsController.cs | 2 +- src/Bootstrapper/Controllers/v1/ProductsController.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bootstrapper/Controllers/v1/BrandsController.cs b/src/Bootstrapper/Controllers/v1/BrandsController.cs index 4f2846f8f8..971c304da0 100644 --- a/src/Bootstrapper/Controllers/v1/BrandsController.cs +++ b/src/Bootstrapper/Controllers/v1/BrandsController.cs @@ -18,7 +18,7 @@ public BrandsController(IBrandService service) [HttpGet] [MustHavePermission(Permissions.Brands.ListAll)] - public async Task GetListAsync(BrandListFilter filter) + public async Task GetListAsync([FromQuery]BrandListFilter filter) { var productDetails = await _service.GetBrandsAsync(filter); return Ok(productDetails); diff --git a/src/Bootstrapper/Controllers/v1/ProductsController.cs b/src/Bootstrapper/Controllers/v1/ProductsController.cs index c6081146f3..ab72c5fe40 100644 --- a/src/Bootstrapper/Controllers/v1/ProductsController.cs +++ b/src/Bootstrapper/Controllers/v1/ProductsController.cs @@ -28,7 +28,7 @@ public async Task GetAsync(Guid id) [HttpGet] [MustHavePermission(Permissions.Products.ListAll)] - public async Task GetListAsync(ProductListFilter filter) + public async Task GetListAsync([FromQuery]ProductListFilter filter) { var productDetails = await _service.GetProductsAsync(filter); return Ok(productDetails);