- Implemented Create, Delete, Get, and Update validators for Product Galleries. - Added Create, Delete, Get, and Update validators for Product Tags. - Created service classes for handling Discount Categories, Discount Orders, Discount Products, Discount Shopping Cart, Product Categories, Product Galleries, and Product Tags. - Each service class integrates with CQRS for command and query handling. - Established mapping profiles for Product Galleries.
23 lines
790 B
C#
23 lines
790 B
C#
namespace CMSMicroservice.Application.UserCartsCQ.Queries.GetUserCarts;
|
|
public class GetUserCartsQueryHandler : IRequestHandler<GetUserCartsQuery, GetUserCartsResponseDto>
|
|
{
|
|
private readonly IApplicationDbContext _context;
|
|
|
|
public GetUserCartsQueryHandler(IApplicationDbContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<GetUserCartsResponseDto> Handle(GetUserCartsQuery request,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
var response = await _context.UserCarts
|
|
.AsNoTracking()
|
|
.Where(x => x.Id == request.Id)
|
|
.ProjectToType<GetUserCartsResponseDto>()
|
|
.FirstOrDefaultAsync(cancellationToken);
|
|
|
|
return response ?? throw new NotFoundException(nameof(UserCart), request.Id);
|
|
}
|
|
}
|