private void UpdateExistingSpecification(IEnumerable <PriceSpecification> specifications) { var existingJuiceInfo = specifications.Where( s => JuiceStockDataCollection.All(c => c.Name == s.Name)); foreach (var specification in existingJuiceInfo) { var spec = JuiceStockDataCollection.First(data => data.Name == specification.Name); spec.Price = specification.Price; spec.CanBuy = _vendingMachine.CanBuy(specification.Name); } }
private void AddSpecification(IEnumerable <PriceSpecification> specifications) { var newJuiceInfo = specifications.Where( s => JuiceStockDataCollection.All(c => c.Name != s.Name)); foreach (var specification in newJuiceInfo) { JuiceStockDataCollection.Add( new JuiceStockData { Name = specification.Name, Price = specification.Price, CanBuy = _vendingMachine.CanBuy(specification.Name) }); } }