private void GetInventory(Location location) { List <Stock> inventories = _shopBL.GetInventory(location); bool repeat = true; Console.WriteLine($"\nDisplaying inventory of Store located at {location.City}, {location.State}:"); int i = 0; foreach (Stock stock in inventories) { Console.WriteLine("[" + ++i + "] " + stock.ToString()); } Console.WriteLine("Would you like to start a new order at this store?"); Console.WriteLine("[1] yes"); Console.WriteLine("[2] no"); bool repeat2 = true; do { string input2 = Console.ReadLine(); switch (input2) { case "yes": case "1": Log.Information("Selected start a new order"); repeat2 = false; break; case "no": case "2": repeat2 = false; repeat = false; return; default: Console.WriteLine("invalid input"); break; } } while (repeat2); Order newOrder = new Order(_user, location, 0.0, DateTime.Now); do { Console.WriteLine("Select an item to add to your order. Otherwise type [0] to go back."); string input = Console.ReadLine(); int n; if (int.TryParse(input, out n)) { if (input == "0") { Console.WriteLine("Returning to Locations Menu..."); repeat = false; } else if (n > 0 && n <= inventories.Count) { Log.Information($"Selected {inventories[n - 1].Product.Name}"); newOrder = AddToOrder(inventories[n - 1], newOrder); bool repeat3 = true; do { Console.WriteLine("Would you like to add another item to your order?"); Console.WriteLine("[1] Add more items"); Console.WriteLine("[2] View Order and checkout"); Console.WriteLine("[0] Exit (you will lose your order)"); string input2 = Console.ReadLine(); switch (input2) { case "1": repeat3 = false; break; case "2": Console.WriteLine(); Console.WriteLine(newOrder.ToString()); Console.WriteLine("Would you like to check out and complete your order?"); Console.WriteLine("[1] yes, check out"); Console.WriteLine("[2] no, go back"); bool repeat4 = true; do { string input4 = Console.ReadLine(); switch (input4) { case "1": case "yes": Log.Information("Completed order"); Order addedOrder = _shopBL.AddOrder(newOrder); Console.WriteLine("Order completed!"); repeat = false; repeat3 = false; repeat4 = false; break; case "2": case "no": repeat4 = false; break; default: Console.WriteLine("invalid input"); break; } } while (repeat4); break; case "0": repeat3 = false; repeat = false; break; default: Console.WriteLine("invalid input"); break; } } while (repeat3); } else { Console.WriteLine("invalid input"); } } else { Console.WriteLine("invalid input"); } } while (repeat); }
private void ReplenishInv(Location location) { List <Stock> inventory = _shopBL.GetInventory(location); Console.WriteLine($"\nDisplaying Inventory to update at store located at {location.City}, {location.State}:"); int i = 0; foreach (Stock stock in inventory) { Console.WriteLine("[" + ++i + "] " + stock.ToString()); } bool repeat = true; do { Console.WriteLine("Select an item to replenish. Otherwise type [0] to go back."); string input = Console.ReadLine(); int n; if (int.TryParse(input, out n)) { if (n == 0) { repeat = false; return; } else if (n > 0 && n <= inventory.Count) { Log.Information($"Selected color {inventory[n - 1].Product.Name}"); bool repeat2 = true; do { Console.WriteLine($"Input how much of color {inventory[n - 1].Product.Name} you would like to add? Otherwise type [0] to go back."); string quantity = Console.ReadLine(); int num; if (int.TryParse(quantity, out num)) { if (num == 0) { repeat2 = false; return; } if (num > 0) { Log.Information($"Selected to add {num} of stock to inventory"); // add to stock Stock addedStock = _shopBL.AddStock(inventory[n - 1], location, num); if (addedStock == null) { Console.WriteLine("Inventory could not be updated. (Server side error)"); } else { Console.WriteLine($"Successfully updated stock for color {inventory[n - 1].Product.Name}"); } return; } } Console.WriteLine("Invalid input"); } while (repeat2); } else { Console.WriteLine("Invalid input"); } } else { Console.WriteLine("Invalid input"); } } while (repeat); }