update
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
namespace BackOffice.BFF.Application.ProductsCQ.Queries.GetAllProductsByFilter;
|
||||
public record GetAllProductsByFilterQuery : IRequest<GetAllProductsByFilterResponseDto>
|
||||
{
|
||||
public PaginationState? PaginationState { get; init; }
|
||||
public string? SortBy { get; init; }
|
||||
public GetAllProductsByFilterFilter? Filter { get; init; }
|
||||
}
|
||||
|
||||
public class GetAllProductsByFilterFilter
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? ShortInfomation { get; set; }
|
||||
public string? FullInformation { get; set; }
|
||||
public long? Price { get; set; }
|
||||
public int? Discount { get; set; }
|
||||
public int? Rate { get; set; }
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
using BackOffice.BFF.Application.Common.Interfaces;
|
||||
using CMSMicroservice.Protobuf.Protos.Products;
|
||||
|
||||
namespace BackOffice.BFF.Application.ProductsCQ.Queries.GetAllProductsByFilter;
|
||||
public class GetAllProductsByFilterQueryHandler : IRequestHandler<GetAllProductsByFilterQuery, GetAllProductsByFilterResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetAllProductsByFilterQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetAllProductsByFilterResponseDto> Handle(GetAllProductsByFilterQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.Products.GetAllProductsByFilterAsync(request.Adapt<GetAllProductsByFilterRequest>(), cancellationToken: cancellationToken);
|
||||
return response.Adapt<GetAllProductsByFilterResponseDto>();
|
||||
}
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
namespace BackOffice.BFF.Application.ProductsCQ.Queries.GetAllProductsByFilter;
|
||||
public class GetAllProductsByFilterResponseDto
|
||||
{
|
||||
public MetaData MetaData { get; set; }
|
||||
public List<GetAllProductsByFilterResponseModel>? Models { get; set; }
|
||||
}
|
||||
|
||||
public class GetAllProductsByFilterResponseModel
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string ShortInfomation { get; set; }
|
||||
public string FullInformation { get; set; }
|
||||
public long Price { get; set; }
|
||||
public int Discount { get; set; }
|
||||
public int Rate { get; set; }
|
||||
public string ImagePath { get; set; }
|
||||
public string ThumbnailPath { get; set; }
|
||||
public int SaleCount { get; set; }
|
||||
public int ViewCount { get; set; }
|
||||
public int RemainingCount { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace BackOffice.BFF.Application.ProductsCQ.Queries.GetProducts;
|
||||
public record GetProductsQuery : IRequest<GetProductsResponseDto>
|
||||
{
|
||||
public long Id { get; init; }
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
using BackOffice.BFF.Application.Common.Interfaces;
|
||||
using CMSMicroservice.Protobuf.Protos.Products;
|
||||
|
||||
namespace BackOffice.BFF.Application.ProductsCQ.Queries.GetProducts;
|
||||
public class GetProductsQueryHandler : IRequestHandler<GetProductsQuery, GetProductsResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetProductsQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetProductsResponseDto> Handle(GetProductsQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _context.Products.GetProductsAsync(request.Adapt<GetProductsRequest>(), cancellationToken: cancellationToken);
|
||||
return response.Adapt<GetProductsResponseDto>();
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
namespace BackOffice.BFF.Application.ProductsCQ.Queries.GetProducts;
|
||||
public class GetProductsResponseDto
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string ShortInfomation { get; set; }
|
||||
public string FullInformation { get; set; }
|
||||
public long Price { get; set; }
|
||||
public int Discount { get; set; }
|
||||
public int Rate { get; set; }
|
||||
public string ImagePath { get; set; }
|
||||
public string ThumbnailPath { get; set; }
|
||||
public int SaleCount { get; set; }
|
||||
public int ViewCount { get; set; }
|
||||
public int RemainingCount { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user