public void AddStock(JuiceStockInfo juiceStockInfo) { var stock = GetStock(juiceStockInfo); if (stock != null) { stock.Count += juiceStockInfo.Count; stock.Price = juiceStockInfo.Price; } else { _juiceStockInfoCollection.Add(juiceStockInfo); } }
private JuiceStockInfo GetStock(JuiceStockInfo stockInfo) { return _juiceStockInfoCollection .FirstOrDefault(info => info.Name == stockInfo.Name); }