コード例 #1
0
 private static string GetCartWeightValue(IStandardShippingCalculation calculation)
 {
     return calculation.UpperBound.HasValue
         ? string.Format("{0}kg to {1}kg", calculation.LowerBound.ToString("0.00"),
             calculation.UpperBound.Value.ToString("#.##"))
         : string.Format("{0}kg or greater", calculation.LowerBound.ToString("0.00"));
 }
コード例 #2
0
 private static string GetCartWeightValue(IStandardShippingCalculation calculation)
 {
     return(calculation.UpperBound.HasValue
         ? string.Format("{0}kg to {1}kg", calculation.LowerBound.ToString("0.00"),
                         calculation.UpperBound.Value.ToString("#.##"))
         : string.Format("{0}kg or greater", calculation.LowerBound.ToString("0.00")));
 }
コード例 #3
0
 private static string GetCartTotalValue(IStandardShippingCalculation calculation)
 {
     return calculation.UpperBound.HasValue
         ? string.Format("{0} to {1}", calculation.LowerBound.ToString("0.00"),
             calculation.UpperBound.Value.ToString("0.00"))
         : string.Format("{0} or greater", calculation.LowerBound.ToString("0.00"));
 }
コード例 #4
0
        public static bool CanBeUsed(this IStandardShippingCalculation calculation, CartModel cart)
        {
            switch (calculation.ShippingCriteria)
            {
            case ShippingCriteria.ByWeight:
                return(IsValid(calculation, cart.Weight));

            case ShippingCriteria.ByCartTotal:
                return(IsValid(calculation, cart.ShippableCalculationTotal()));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #5
0
        public static string GetDescription(this IStandardShippingCalculation calculation)
        {
            switch (calculation.ShippingCriteria)
            {
            case ShippingCriteria.ByWeight:
                return(string.Format("Cart weight: {0}", GetCartWeightValue(calculation)));

            case ShippingCriteria.ByCartTotal:
                return(string.Format("Cart total: {0}", GetCartTotalValue(calculation)));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #6
0
 public static decimal Tax(this IStandardShippingCalculation calculation, decimal taxRate)
 {
     return(calculation.BaseAmount.ShippingTax(taxRate));
 }
コード例 #7
0
 private static bool IsValid(IStandardShippingCalculation calculation, decimal value)
 {
     return(value >= calculation.LowerBound &&
            (!calculation.UpperBound.HasValue || value <= calculation.UpperBound));
 }
コード例 #8
0
 private static bool IsValid(IStandardShippingCalculation calculation, decimal value)
 {
     return value >= calculation.LowerBound &&
            (!calculation.UpperBound.HasValue || value <= calculation.UpperBound);
 }