public decimal CalculateTotal(ICoupon coupon, Dictionary <string, IOffer> currentOffers) { var total = Products.Sum(kv => { var product = kv.Value.Product; var quantity = kv.Value.Quantity; if (currentOffers != null && currentOffers.ContainsKey(product.Name)) { return(currentOffers[product.Name].ApplyOffer(product, quantity)); } return(product.Price * quantity); }); if (coupon != null) { return(coupon.ApplyDiscount(total)); } return(total); }