This commit is contained in:
masoodafar-web
2025-11-17 20:58:12 +03:30
parent 4f038d33f3
commit 2446b2b76b
4 changed files with 211 additions and 293 deletions

View File

@@ -13,7 +13,7 @@ public class GetAllProductsByFilterQueryHandler : IRequestHandler<GetAllProducts
public async Task<GetAllProductsByFilterResponseDto> Handle(GetAllProductsByFilterQuery request, CancellationToken cancellationToken)
{
await _context.Package.GetAllPackageByFilterAsync(request.Adapt<GetAllPackageByFilterRequest>(), cancellationToken: cancellationToken);
return new GetAllProductsByFilterResponseDto();
var result= await _context.Package.GetAllPackageByFilterAsync(request.Adapt<GetAllPackageByFilterRequest>(), cancellationToken: cancellationToken);
return result.Adapt<GetAllProductsByFilterResponseDto>();
}
}

View File

@@ -1,3 +1,5 @@
using CMSMicroservice.Protobuf.Protos.Products;
namespace FrontOffice.BFF.Application.ProductsCQ.Queries.GetProducts;
public class GetProductsQueryHandler : IRequestHandler<GetProductsQuery, GetProductsResponseDto>
{
@@ -11,12 +13,8 @@ public class GetProductsQueryHandler : IRequestHandler<GetProductsQuery, GetProd
public async Task<GetProductsResponseDto> Handle(GetProductsQuery request,
CancellationToken cancellationToken)
{
var response = await _context.Productss
.AsNoTracking()
.Where(x => x.Id == request.Id)
.ProjectToType<GetProductsResponseDto>()
.FirstOrDefaultAsync(cancellationToken);
var response = await _context.Product.GetProductsAsync(request.Adapt<GetProductsRequest>(), cancellationToken: cancellationToken);
return response ?? throw new NotFoundException(nameof(Products), request.Id);
return response ==null? throw new NotFoundException(nameof(ProductsContract.ProductsContractClient), request.Id):response.Adapt<GetProductsResponseDto>();
}
}

View File

@@ -1,4 +1,4 @@
using FrontOffice.BFF.Protobuf.Protos.Products;
using CMSMicroservice.Protobuf.Protos.Products;
using FrontOffice.BFF.WebApi.Common.Services;
using FrontOffice.BFF.Application.ProductsCQ.Queries.GetProducts;
using FrontOffice.BFF.Application.ProductsCQ.Queries.GetAllProductsByFilter;