namespace CMSMicroservice.Application.UserWalletChangeLogCQ.Queries.GetUserWalletChangeLog;
public class GetUserWalletChangeLogQueryHandler : IRequestHandler<GetUserWalletChangeLogQuery, GetUserWalletChangeLogResponseDto>
{
    private readonly IApplicationDbContext _context;

    public GetUserWalletChangeLogQueryHandler(IApplicationDbContext context)
    {
        _context = context;
    }

    public async Task<GetUserWalletChangeLogResponseDto> Handle(GetUserWalletChangeLogQuery request,
        CancellationToken cancellationToken)
    {
        var response = await _context.UserWalletChangeLogs
            .AsNoTracking()
            .Where(x => x.Id == request.Id)
            .ProjectToType<GetUserWalletChangeLogResponseDto>()
            .FirstOrDefaultAsync(cancellationToken);

        return response ?? throw new NotFoundException(nameof(UserWalletChangeLog), request.Id);
    }
}
