Api/Netina.Repository/Handlers/Discounts/GetDiscountsQueryHandler.cs

16 lines
664 B
C#
Raw Normal View History

2024-08-09 21:55:16 +03:30
namespace Netina.Repository.Handlers.Discounts;
2024-02-12 22:01:15 +03:30
2024-08-09 21:55:16 +03:30
public class GetDiscountsQueryHandler(IRepositoryWrapper repositoryWrapper)
: IRequestHandler<GetDiscountsQuery, List<DiscountSDto>>
{
public async Task<List<DiscountSDto>> Handle(GetDiscountsQuery request, CancellationToken cancellationToken)
{
2024-08-09 21:55:16 +03:30
var discounts = await repositoryWrapper.SetRepository<Discount>().TableNoTracking
.Where(d=>!d.IsSpecialOffer)
.OrderByDescending(b => b.CreatedAt)
2024-02-03 10:34:48 +03:30
.Skip(request.Page * 15).Take(15)
.Select(DiscountMapper.ProjectToSDto)
.ToListAsync(cancellationToken);
2024-04-15 16:38:58 +03:30
return discounts;
}
}