/// <summary> /// this takes a DB context and allows user to choose an order ID and search a its details /// </summary> /// <param name="context"></param> public static void OrderDetails(DBRepository repo) { //get list of all orders var orders = repo.ReadAllOrdersInTable(); //list all customers Console.WriteLine("Please choose a Order ID number from the list below to display the items in it."); foreach (var item in orders) { Console.WriteLine($"OrderID =>{item.OrderId} -- LocationID =>{item.LocationId} -- CustomerID =>{item.CustomerId}"); } string usersChoice = Console.ReadLine(); int usersChoice1 = Convert.ToInt32(usersChoice); var orderToDisplay = orders .Where(x => x.OrderId == usersChoice1).First(); int orderProdsToDisplay = orderToDisplay.OrderId; //get all that customers orders Order custOrders = repo.ReadOrderByOrderId(orderProdsToDisplay); //display all orders Console.WriteLine($"Here are the items in order #{usersChoice1}\n======================================="); foreach (var item in custOrders.itemsOrdered) { Console.WriteLine($"\t={item.Key}= ={item.Value}="); } }
/// <summary> /// This takes a DB context and allows the user to view the order history of a particular location /// </summary> /// <param name="context"></param> public static void LocationHistory(DBRepository repo) { Console.WriteLine("Please enter the NUMBER of the location you'd like to see the order history of."); var locations = repo.ReadAllLocations(); foreach (var item in locations) { Console.WriteLine($"\t{item.LocationId}---{item.LocationName}"); } string response = Console.ReadLine(); int response1 = Convert.ToInt32(response); //get all orders and sort them by locationID var locOrders = repo.ReadAllOrdersInTable(); foreach (var item in locOrders) { Console.WriteLine($"\tLocationID => {item.LocationId}-----OrderID => {item.OrderId}-----CustomerID => {item.CustomerId}---"); } Console.WriteLine("This is the order history of this location"); }