16 lines
664 B
C#
16 lines
664 B
C#
namespace Netina.Repository.Handlers.Discounts;
|
|
|
|
public class GetDiscountsQueryHandler(IRepositoryWrapper repositoryWrapper)
|
|
: IRequestHandler<GetDiscountsQuery, List<DiscountSDto>>
|
|
{
|
|
public async Task<List<DiscountSDto>> Handle(GetDiscountsQuery request, CancellationToken cancellationToken)
|
|
{
|
|
var discounts = await repositoryWrapper.SetRepository<Discount>().TableNoTracking
|
|
.Where(d=>!d.IsSpecialOffer)
|
|
.OrderByDescending(b => b.CreatedAt)
|
|
.Skip(request.Page * 15).Take(15)
|
|
.Select(DiscountMapper.ProjectToSDto)
|
|
.ToListAsync(cancellationToken);
|
|
return discounts;
|
|
}
|
|
} |