/// <summary> /// Sell Products /// </summary> private void Sell() { int numberOfUnits = _consoleView.DisplayGetNumberOfUnitsToSell(_salesperson.CurrentStock); _salesperson.CurrentStock.SubtractProducts(numberOfUnits); if (_salesperson.CurrentStock.OnBackOrder) { _consoleView.DisplayBackorderNotification(_salesperson.CurrentStock, numberOfUnits); } }
/// <summary> /// sell product /// </summary> private void Sell() { int numberOfUnits = _consoleView.DisplayGetNumberOfUnitsToSell(_salesperson.CurrentStock); _salesperson.CurrentStock.SubtractProducts(numberOfUnits); // if number of units to sell is less than current stock, run backorder notifaction if (_salesperson.CurrentStock.OnBackorder) { _consoleView.DisplayBackorderNotification(_salesperson.CurrentStock, numberOfUnits); } }
private void Sell() { if (_salesperson.CurrentStock.Count() <= 0) { _consoleView.DisplayInventoryError(); return; } Product selectedProduct = _consoleView.DisplayGetNumberOfUnitsToSell(_salesperson.CurrentStock); Product targetProduct = _salesperson.CurrentStock.Find(x => x.Type == selectedProduct.Type); targetProduct.SubtractProducts(selectedProduct.NumberOfUnits); if (targetProduct.OnBackorder) { _consoleView.DisplayBackorderNotification(targetProduct, selectedProduct.NumberOfUnits); _salesperson.Logs.Push(DateTime.Now + " ... Backordered " + selectedProduct.NumberOfUnits + " " + selectedProduct.Type + "!"); } else { _salesperson.Logs.Push(DateTime.Now + " ... Sold " + selectedProduct.NumberOfUnits + " " + selectedProduct.Type + "!"); } }