Exemple #1
0
        public async Task <ActionResult <List <CouponDto> > > GetAllAvailableCouponAsync()
        {
            _logger.LogInformation("----- Get all available coupons");

            var allCoupons = await _couponRepository.GetAllAvailableCouponsAsync();

            if (allCoupons is null || !allCoupons.GetEnumerator().MoveNext())
            {
                return(Ok("No coupon available for consumption."));
            }

            var returnList = new List <CouponDto>();

            allCoupons.ToList().ForEach(c =>
                                        returnList.Add(new CouponDto()
            {
                Code     = c.Code,
                Discount = c.Discount
            }
                                                       ));

            return(Ok(returnList));
        }