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 }); } }
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; }
public static bool FirstOf(this IPricingRule priceRule, OrderItem item) { return(priceRule.IsMatch(item)); }
public void AddPricingRule(IPricingRule rule) { pricingRuleList.Add(rule); }
public Item(Sku sku, decimal unitPrice, IPricingRule pricingRule) { Sku = sku; UnitPrice = unitPrice; PricingRule = pricingRule; }