This commit is contained in:
masoodafar-web
2025-11-26 23:10:03 +03:30
parent eda91d4f1f
commit 020f0479ad
19 changed files with 977 additions and 0 deletions
@@ -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; }
}
@@ -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>();
}
}
@@ -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; }
}
@@ -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>();
}
}
@@ -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; }
}