add version 0.17.17.24
parent
77c56f003a
commit
3da4aad198
|
@ -21,10 +21,11 @@ public class GetBrandsQueryHandler : IRequestHandler<GetBrandsQuery, List<BrandS
|
||||||
{
|
{
|
||||||
//var products = await _mediator.Send(new GetProductsQuery(BrandIds: null,SpecialOffer: null, Page:0, SortBy: QuerySortBy.None,CategoryId: request.CategoryId, IsActive : null),
|
//var products = await _mediator.Send(new GetProductsQuery(BrandIds: null,SpecialOffer: null, Page:0, SortBy: QuerySortBy.None,CategoryId: request.CategoryId, IsActive : null),
|
||||||
// cancellationToken);
|
// cancellationToken);
|
||||||
var brandGrouped = _repositoryWrapper.SetRepository<Product>()
|
var brandGrouped = await _repositoryWrapper.SetRepository<Product>()
|
||||||
.TableNoTracking
|
.TableNoTracking
|
||||||
.Where(p => p.CategoryId == request.CategoryId)
|
.Where(p => p.CategoryId == request.CategoryId)
|
||||||
.GroupBy(p=>p.BrandId);
|
.GroupBy(p=>p.BrandId)
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
foreach (var grouping in brandGrouped)
|
foreach (var grouping in brandGrouped)
|
||||||
{
|
{
|
||||||
if (grouping.Key != default)
|
if (grouping.Key != default)
|
||||||
|
|
|
@ -66,16 +66,19 @@ public class GetProductsQueryHandler : IRequestHandler<GetProductsQuery, GetProd
|
||||||
response.Pager.TotalItems = await products.CountAsync(cancellationToken);
|
response.Pager.TotalItems = await products.CountAsync(cancellationToken);
|
||||||
response.Pager.TotalPage = response.Pager.TotalItems % 20 == 0 ? response.Pager.TotalItems / 20 : (response.Pager.TotalItems / 20) + 1;
|
response.Pager.TotalPage = response.Pager.TotalItems % 20 == 0 ? response.Pager.TotalItems / 20 : (response.Pager.TotalItems / 20) + 1;
|
||||||
|
|
||||||
|
if(await products.AnyAsync(cancellationToken))
|
||||||
|
{
|
||||||
|
response.Filters.Price.MaximumValue = await products.MaxAsync(p => p.Cost, cancellationToken);
|
||||||
|
response.Filters.Price.MinimumValue = await products.MinAsync(p => p.Cost, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
List<ProductSDto> productSDtos = await products
|
List<ProductSDto> productSDtos = await products
|
||||||
.Skip(request.Page * 20)
|
.Skip(request.Page * 20)
|
||||||
.Take(20)
|
.Take(20)
|
||||||
.Select(ProductMapper.ProjectToSDto)
|
.Select(ProductMapper.ProjectToSDto)
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
response.Filters.Price.MaximumValue = await products.MaxAsync(p => p.Cost,cancellationToken);
|
|
||||||
response.Filters.Price.MinimumValue = await products.MinAsync(p => p.Cost,cancellationToken);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach (var productSDto in productSDtos)
|
foreach (var productSDto in productSDtos)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue