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"));
 }
Example #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")));
 }
 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"));
 }
Example #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();
            }
        }
Example #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();
            }
        }
Example #6
0
 public static decimal Tax(this IStandardShippingCalculation calculation, decimal taxRate)
 {
     return(calculation.BaseAmount.ShippingTax(taxRate));
 }
Example #7
0
 private static bool IsValid(IStandardShippingCalculation calculation, decimal value)
 {
     return(value >= calculation.LowerBound &&
            (!calculation.UpperBound.HasValue || value <= calculation.UpperBound));
 }
 private static bool IsValid(IStandardShippingCalculation calculation, decimal value)
 {
     return value >= calculation.LowerBound &&
            (!calculation.UpperBound.HasValue || value <= calculation.UpperBound);
 }