コード例 #1
0
 public void Add(Product product, IPricingRule rule, RulePriority rulePriority = RulePriority.High)
 {
     if (_dict.TryGetValue(product.Code.Trim(), out List <IPricingRule> rls))
     {
         rls.Add(rule);
         _dict.Remove(product.Code.Trim());
         _dict.Add(product.Code.Trim(), rls);
     }
     else
     {
         _dict.Add(product.Code.Trim(), new List <IPricingRule> {
             rule
         });
     }
 }
コード例 #2
0
        public DiscountPricingRule(int threshholdUnits, decimal discountPrice,
                                   IPricingRule regularPricingRule)
        {
            //Validations
            if (threshholdUnits < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(threshholdUnits));
            }
            if (discountPrice < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(discountPrice));
            }
            if (regularPricingRule == null)
            {
                throw new ArgumentNullException(nameof(regularPricingRule));
            }

            // Init fields
            _threshholdUnits    = threshholdUnits;
            _discountPrice      = discountPrice;
            _regularPricingRule = regularPricingRule;
        }
コード例 #3
0
 public static bool FirstOf(this IPricingRule priceRule, OrderItem item)
 {
     return(priceRule.IsMatch(item));
 }
コード例 #4
0
 public void AddPricingRule(IPricingRule rule)
 {
     pricingRuleList.Add(rule);
 }
コード例 #5
0
 public void AddPricingRule(IPricingRule rule)
 {
     pricingRuleList.Add(rule);
 }
コード例 #6
0
 public Item(Sku sku, decimal unitPrice, IPricingRule pricingRule)
 {
     Sku         = sku;
     UnitPrice   = unitPrice;
     PricingRule = pricingRule;
 }