private double GetPrice(SkuCart cart) { // Getting popilated prices for each product (master data) IDictionary <char, double> priceOfEachItem = cart.GetAvailableProductsWithPrice(); double totalPrice = 0; bool IsComboRule = checkForComboRule(); foreach (var Product in _purchasedProductCount) { //Getting Rule defined for each product (sku id's) Tuple <int, double> Rule = PromotionRules.GetRule(Product.Key); if (Rule != null) { //applying rule and calculating total price totalPrice += (Product.Value / Rule.Item1) * Rule.Item2 + (Product.Value % Rule.Item1) * priceOfEachItem[Product.Key]; } else //if there is no rule and it is not combo product(sku id) then calculating it's price if (!IsComboRule) { totalPrice += priceOfEachItem[Product.Key] * Product.Value; } } if (!IsComboRule) { return(totalPrice); } else { return(caluculateComboRule(totalPrice, priceOfEachItem)); } }