// Apply Promotions mutually exclusive which will be called from user after fillling the cart public decimal ApplyPromotionsAll(Dictionary <Product, int> productsInCart) { productsStock = new ProductStock(); promotionsList = new Dictionary <Promotion, decimal>(); Promotion prom1 = new Promotion("Applied All Promotions", promotionForAll); return(prom1.afterPromotionApplied(productsInCart)); }
// Apply Promotions mutually exclusive which will be called from user after fillling the cart public decimal ApplyPromotionsMutuallyExclusive(Dictionary <Product, int> productsInCart) { productsStock = new ProductStock(); promotionsList = new Dictionary <Promotion, decimal>(); Promotion prom1 = new Promotion("Promotion For Product A", promotionForProd_A); Promotion prom2 = new Promotion("Promotion For Product B", promotionForProd_B); Promotion prom3 = new Promotion("Promotion For Product C_D", promotionForProd_C_D); //All promotions will be applied for cart individually promotionsList.Add(prom1, prom1.afterPromotionApplied(productsInCart)); promotionsList.Add(prom2, prom2.afterPromotionApplied(productsInCart)); promotionsList.Add(prom3, prom3.afterPromotionApplied(productsInCart)); //The promotion which return minimum of cart values will be returned return(promotionsList.Aggregate((l, r) => l.Value < r.Value ? l : r).Value); }