private bool QualifiesForOffer(Product item) { if (item.Offer == null) { return false; } return _bag.Count(x => x.Sku == item.Sku && !x.IsBilled) >= item.Offer.Count; }
private void ApplyOffer(Product product) { product.TotalPrice = product.Offer.Price; var productsInOffering = _bag.Where(x => x.Sku == product.Sku && !x.IsBilled) .Take(product.Offer.Count); foreach (var p in productsInOffering) { p.IsBilled = true; } }
public void Scan(string sku) { var product = _prices.Single(x => x.Sku == sku); var item = new Product { Sku = product.Sku, Price = product.Price, Offer = product.Offer }; _bag.Add(item); }