Generator Changes at 11/12/2025 1:32:03 AM +03:30
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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.UserCartss
|
||||
.AsNoTracking()
|
||||
.Where(x => x.Id == request.Id)
|
||||
.ProjectToType<GetUserCartsResponseDto>()
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
return response ?? throw new NotFoundException(nameof(UserCarts), request.Id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user