private PromotionMatch TryMatchPromotion(Promotion promotion, PriceCalculationContext context) { if (promotion.RequireCouponCode && context.CouponCode != promotion.CouponCode) { return(null); } var isMatch = false; var conditionMatchedItems = new List <PriceCalculationItem>(); if (!promotion.Conditions.Any()) { isMatch = true; } else { var conditionChecker = new PromotionConditionChecker(_ruleEngine); var result = conditionChecker.CheckConditions(promotion, context); if (result.Success) { isMatch = true; foreach (var item in result.MatchedItems) { if (!conditionMatchedItems.Contains(item)) { conditionMatchedItems.Add(item); } } } } if (isMatch) { return(new PromotionMatch(promotion, conditionMatchedItems)); } return(null); }
private PromotionMatch TryMatchPromotion(Promotion promotion, PriceCalculationContext context) { if (promotion.RequireCouponCode && context.CouponCode != promotion.CouponCode) { return null; } var isMatch = false; var conditionMatchedItems = new List<PriceCalculationItem>(); if (!promotion.Conditions.Any()) { isMatch = true; } else { var conditionChecker = new PromotionConditionChecker(_ruleEngine); var result = conditionChecker.CheckConditions(promotion, context); if (result.Success) { isMatch = true; foreach (var item in result.MatchedItems) { if (!conditionMatchedItems.Contains(item)) { conditionMatchedItems.Add(item); } } } } if (isMatch) { return new PromotionMatch(promotion, conditionMatchedItems); } return null; }