///<summary> ///Method to place order by passing business logic order object to data handler ///</summary> private void AddOrder() { OrderHandler oh = new OrderHandler(); LocationHandler lh = new LocationHandler(); Customer c = new Customer(); Console.WriteLine("New Customer? \n Y^(YES) N^(NO))"); string input = Console.ReadLine(); switch (input) { case "Y": AdminCustomer ac = new AdminCustomer(); c = ac.AddNewCustomer(); break; case "N": c = EnterCustomerDetails(); break; default: ErrorHandler err = new ErrorHandler(); err.InvalidInputMsg(); AddOrder(); break; } Location l = EnterLocationDetails(); string choice; List <Inventory> custOrder = new List <Inventory>(); do { Console.WriteLine("Choose Product to Order (Enter Index Number):"); List <Inventory> availInvent = lh.GetAvailInventory(l); int j = 0; foreach (Inventory i in availInvent) { Console.WriteLine("[" + j + "] " + " Name: " + i.Prod.Name + "\n Price: " + i.Prod.Price + "\n Remaining Stock: " + i.Stock); j++; } input = Console.ReadLine(); Console.WriteLine("Enter Quantity: "); string amount = Console.ReadLine(); try { lh.UpdateInventory(new Inventory() { Prod = availInvent[int.Parse(input)].Prod, Stock = int.Parse(amount) }, l); } catch (InsufficientStockException ex) { Console.WriteLine(ex.Message); choice = ""; Log.Error("Insufficient Stock Exception. User tried to buy products more than available inventory"); continue; } catch (FormatException ex) { Console.WriteLine(ex.Message); choice = ""; Log.Error("Format Exception. User tried to input invalid format"); continue; } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); choice = ""; Log.Error(ex.Message); continue; } catch (InvalidStockException ex) { Console.WriteLine(ex.Message); choice = ""; Log.Error(ex.Message); continue; } custOrder.Add(new Inventory() { Prod = availInvent[int.Parse(input)].Prod, Stock = int.Parse(amount) }); do { Console.WriteLine("Would you like to order another product? \n N^(NO) Y^(YES)"); choice = Console.ReadLine(); } while (ErrorHandler.InvalidInput(choice)); } while (choice != "N"); Orders o = new Orders() { Cust = c, Stor = l, Date = DateTime.Now, CustOrder = custOrder }; oh.AddOrder(o); oh.PrintOrderDetails(o); Log.Information("Order Added"); Log.Information($"Order was made by customer {c.FirstName} {c.LastName} at {l.BranchName} store"); Menu(); }