static void DisplaySpecificOrder(IProject0Repository projectRepository) { int orderId = 0; var specificOrder = new Orders(); while (orderId == 0 && specificOrder.Id == 0) { _io.Output("Enter Order Id: \n"); try { orderId = Int32.Parse(_io.Input()); specificOrder = projectRepository.GetOrders().First(o => o.Id == orderId); } catch (ArgumentException ex) { _io.Output("Order Id Invalid."); s_logger.Info(ex); Console.WriteLine(ex.Message); } } var productName = projectRepository.GetProductById(specificOrder.ProductId).Name; var customerName = projectRepository.GetCustomerById(specificOrder.CustomerId).FirstName + " " + projectRepository.GetCustomerById(specificOrder.CustomerId).LastName; // locationName = projectRepository.GetLocationsById(specificOrder.CustomerId).LocationName; //_io.Output($"ID: {specificOrder.Id} Product Name: {productName} Quantity: {specificOrder.Quantity} " + // $"Location: {locationName} Customer Name: {customerName} \n"); _io.Output($"ID: {specificOrder.Id} Product Name: {productName} Quantity: {specificOrder.Quantity} " + $" Customer Name: {customerName} \n"); }
static void DisplayCustomerHistory(IProject0Repository projectRepository) { _io.Output("Select an Customer: \n"); var customers = projectRepository.GetCustomers(); var customerList = customers.ToList <Customer>(); int customerId = 0; while (customerId == 0) { foreach (var item in customerList) { _io.Output($"{item.FirstName} {item.LastName} \n"); } string[] customerInput = _io.Input().Split(' '); try { customerId = customers.First(c => c.FirstName.ToLower() == customerInput[0] && c.LastName.ToLower() == customerInput[1]).Id; } catch (ArgumentException ex) { _io.Output("Name Invalid. It does not match any in our database."); s_logger.Info(ex); Console.WriteLine(ex.Message); } } var orderHistory = projectRepository.GetOrders().Where(o => o.CustomerId == customerId).ToList(); foreach (var item in orderHistory) { var productName = projectRepository.GetProductById(item.ProductId).Name; var customerName = projectRepository.GetCustomerById(item.CustomerId).FirstName + " " + projectRepository.GetCustomerById(item.CustomerId).LastName; //var locationName = projectRepository.GetLocationsById(item.CustomerId).LocationName; //_io.Output($"ID: {item.Id} Product Name: {productName} Quantity: {item.Quantity} " + // $"Location: {locationName} Customer Name: {customerName} \n"); _io.Output($"ID: {item.Id} Product Name: {productName} Quantity: {item.Quantity} " + $" Customer Name: {customerName} \n"); } }
static void DisplayLocationHistory(IProject0Repository projectRepository) { _io.Output("Select an Location: \n"); var locations = projectRepository.GetLocations(); var locationList = locations.ToList <StoreLocation>(); int locationId = 0; while (locationId == 0) { foreach (var item in locationList) { _io.Output(item.LocationName + "\n"); } string locationInput = _io.Input(); try { //get store id locationId = locations.First(l => l.LocationName.ToLower() == locationInput).Id; } catch (ArgumentException ex) { _io.Output("Location Id Invalid."); s_logger.Info(ex); Console.WriteLine(ex.Message); } } var orderHistory = projectRepository.GetOrders().Where(o => o.StoreLocationId == locationId).ToList(); foreach (var item in orderHistory) { var productName = projectRepository.GetProductById(item.ProductId).Name; var customerName = projectRepository.GetCustomerById(item.CustomerId).FirstName + " " + projectRepository.GetCustomerById(item.CustomerId).LastName; var locationName = projectRepository.GetLocationsById(item.CustomerId).LocationName; _io.Output($"ID: {item.Id} Product Name: {productName} Quantity: {item.Quantity} " + $" Customer Name: {customerName} \n"); } }