using Microsoft.EntityFrameworkCore; namespace NetinaShop.Repository.Handlers.Discounts; public class GetDiscountsQueryHandler : IRequestHandler> { private readonly IRepositoryWrapper _repositoryWrapper; public GetDiscountsQueryHandler(IRepositoryWrapper repositoryWrapper) { _repositoryWrapper = repositoryWrapper; } public async Task> Handle(GetDiscountsQuery request, CancellationToken cancellationToken) { var discounts = await _repositoryWrapper.SetRepository().TableNoTracking .Where(d=>!d.IsSpecialOffer) .OrderByDescending(b => b.CreatedAt) .Skip(request.Page * 15).Take(15) .Select(DiscountMapper.ProjectToSDto) .ToListAsync(cancellationToken); return discounts; } }