public void UpdateStockLevel(OwnerInventory item) { using (var connection = Program.ConnectionString.CreateConnection()) { connection.Open(); var command = connection.CreateCommand(); command.CommandText = "update OwnerInventory set StockLevel = @stockLevel where ProductID = @productID"; command.Parameters.AddWithValue("stockLevel", item.StockLevel); command.Parameters.AddWithValue("productID", item.ProductID); command.ExecuteNonQuery(); } }
public void UpdateStockLevel(OwnerInventory item) { while (true) { if (item.StockLevel >= 20) { Console.WriteLine("{0} already has enough stock.", item.Name); Console.WriteLine(); return; } item.StockLevel = 20; resetManager.UpdateStockLevel(item); Console.WriteLine("{0} stock level has been reset to 20.", item.Name); Console.WriteLine(); break; } }