// Calculates the total price of the sales invoice after applying the promotions. public float calculatePromotion(Dictionary <string, int> SalesInvoice) { ProductsList products = new ProductsList(); Promotions promotions = new Promotions(); float totalPrice = 0; float promotionsOffers = 0; // Apply each promotion on the sales invoice and get the aggreageted offervalue. foreach (var promotion in promotions.list_of_promotions) { var offer = applyPromotion(promotion, SalesInvoice); promotionsOffers = promotionsOffers + offer; } // Calculate the total price for non promotion items, ie left over items after aplying promotion var saleList = new List <string>(SalesInvoice.Keys); foreach (var sale in saleList) { var price = products.SKUID[sale] * SalesInvoice[sale]; totalPrice = totalPrice + price; Console.WriteLine("Offer:{0} => {1}", price, totalPrice); } Console.WriteLine("Offer:{0}", totalPrice); return(promotionsOffers + totalPrice); }
static void Main(string[] args) { ProductsList productsList = new ProductsList(); PromotionCalculate promotionCalculate = new PromotionCalculate(); promotionCalculate.calculatePromotion(productsList.SKUID); Console.WriteLine("Promotions Engine !"); Console.ReadLine(); }