public async Task <IActionResult> GetDiscounts([FromQuery] DiscountParams discountParams)
        {
            var discounts = await _repo.GetDiscounts(discountParams);

            var discountsToReturn = _mapper.Map <IEnumerable <DiscountReturnDTO> >(discounts);

            Response.AddPagination(discounts.CurrentPage, discounts.PageSize, discounts.TotalCount, discounts.TotalPages);

            return(Ok(discountsToReturn));
        }
Exemplo n.º 2
0
        public async Task <PagedList <Coupon> > GetCoupans(DiscountParams discountParams)
        {
            var discounts = _context.Coupons.AsQueryable();

            discounts = discounts.Where(f => (f.CoupanTitle == discountParams.DiscountName ||
                                              f.CouponCode == discountParams.CouponCode
                                              ));


            return(await PagedList <Coupon> .CreateAsync(discounts, discountParams.PageNumber, discountParams.PageSize));
        }