Пример #1
0
 private double GetDiscount(Coupon coupon, double totalOriginal)
 {
     if (coupon.MinimumAmount > totalOriginal)
     {
         return(totalOriginal);
     }
     return(Convert.ToInt32(coupon.CouponType) switch {
         (int)Coupon.ECouponType.Dollar => Math.Round(totalOriginal - coupon.Discount, 2),
         (int)Coupon.ECouponType.Percent =>
         Math.Round(totalOriginal - (totalOriginal * coupon.Discount / 100), 2),
         _ => totalOriginal
     });
Пример #2
0
        private double DiscountedPrice(Coupon coupon, double originalOrderTotal)
        {
            if (coupon == null || coupon.MinimumAmount > originalOrderTotal)
            {
                return(originalOrderTotal);
            }

            if (coupon.CouponType == ECouponType.Dollar)
            {
                return(originalOrderTotal - coupon.Discount);
            }

            return(originalOrderTotal - ((originalOrderTotal * coupon.Discount) / 100));
        }