コード例 #1
0
        public async Task AddCouponByCodeAsync(string couponCode)
        {
            if (_coupons.Find(o => o.Code == couponCode) != null)
            {
                throw new ArgumentException("Coupon code is already used.");
            }
            else
            {
                ICoupon coupon = await _couponService.GetByCodeAsync(couponCode);

                if (coupon == null)
                {
                    throw new ArgumentException("Invalid coupon code.");
                }
                await AddCouponAsync(coupon);
            }
        }