private static Location RetrieveLocation(BBearContext dbContext, int location_id)
        {
            LocationDB location    = dbContext.Location.Include(x => x.Inventory).ThenInclude(y => y.Product).SingleOrDefault(x => x.LocationId == location_id);
            Location   newlocation = new Location();

            newlocation.ID = location_id;
            newlocation.Inventory["Bear"].Quantity = location.Inventory.Where(x => x.Product.ProductName == "Bear").First().Quantity;
            foreach (Inventory inv in location.Inventory.Where(x => x.Product.ProductName != "Bear"))
            {
                Training p = new Training(inv.Product.ProductName, Convert.ToDouble(inv.Product.DefPrice));
                newlocation.AddProduct(p, inv.Quantity);
            }

            return(newlocation);
        }
        static void Main(string[] args)
        {
            BBearContext dbContext = CreateDbContext();
            bool         running   = true;

            Console.WriteLine("Business Bears: We Sell Bears, Train Bears, And Nothing Else. NO GIRAFFES.");

            while (running)
            {
                Console.WriteLine();
                Console.Write("Choose a submenu, or \"q\" to quit: ");
                Console.WriteLine();
                Console.WriteLine("r:\tCreate & process new order.");
                Console.WriteLine("a:\tView order history.");

                var input = Console.ReadLine();
                if (input == "r")
                {
                    bool customerhandling = true;
                    int  cID = 0;
                    while (customerhandling)
                    {
                        Console.WriteLine("Please input the first or last name of the customer");
                        string          cname = Console.ReadLine();
                        List <Customer> lc    = RetrieveCustomers(dbContext, cname);
                        if (lc.Count() <= 0)
                        {
                            Console.WriteLine("No results for that name. Please try again.");
                        }
                        else
                        {
                            foreach (Customer customer in lc)
                            {
                                customer.CustomerDetails();
                            }
                            Console.WriteLine();
                            Console.WriteLine("Please input the Customer ID from the provided list.");
                            string s = Console.ReadLine();

                            while (!Int32.TryParse(s, out cID) || lc.Count(x => x.Id.Equals(cID)) == 0)
                            {
                                Console.WriteLine("Input must be a number from the provided list");

                                s = Console.ReadLine();
                            }
                            if (!lc.Single(x => x.Id == cID).OrderLimit(DateTime.Now))
                            {
                                Console.WriteLine("This customer has bought bears in the last two hours. Please wait or try another customer.");
                            }
                            else
                            {
                                customerhandling = !customerhandling;
                            }
                        }
                    }


                    Console.WriteLine("How many bears will be required for this order?");


                    string s2 = Console.ReadLine();
                    int    bearcountO;

                    while (!Int32.TryParse(s2, out bearcountO) && bearcountO > 0)
                    {
                        Console.WriteLine("Not a valid number, try again.");

                        s2 = Console.ReadLine();
                    }


                    int counter = 0;
                    HashSet <Training> trainingArray = new HashSet <Training>();
                    List <Bear>        bearList      = new List <Bear>();
                    while (counter < bearcountO)
                    {
                        Console.WriteLine($"Select the training modules needed for Bear #{counter + 1}. Insert 'f' when finished");
                        Console.WriteLine("Note: Only one type of training per bear. Extra modules will be ignored.");
                        Console.WriteLine($"r:\t Juggling - $19.99");
                        Console.WriteLine($"a:\t Fighting - $24.99");
                        Console.WriteLine($"s:\t Tax Evasion - $45.99");
                        Console.WriteLine($"l:\t Marriage Counselling - $69.99");
                        Console.WriteLine($"t:\t Divininty - $199.99");
                        Console.WriteLine($"p:\t C#/.Net  - $2.99");

                        string trainingSelect = Console.ReadLine();
                        if (trainingSelect == "r")
                        {
                            Training t = new Training("Juggling", 19.99);
                            Console.WriteLine("Training module added!");
                            trainingArray.Add(t);
                        }
                        if (trainingSelect == "a")
                        {
                            Training t = new Training("Fighting", 24.99);
                            Console.WriteLine("Training module added!");
                            trainingArray.Add(t);
                        }
                        if (trainingSelect == "s")
                        {
                            Training t = new Training("Tax Evasion", 45.99);
                            Console.WriteLine("Training module added!");
                            trainingArray.Add(t);
                        }
                        if (trainingSelect == "l")
                        {
                            Training t = new Training("Marriage Counselling", 69.99);
                            Console.WriteLine("Training module added!");
                            trainingArray.Add(t);
                        }
                        if (trainingSelect == "t")
                        {
                            Training t = new Training("Divinity", 199.99);
                            Console.WriteLine("Training module added!");
                            trainingArray.Add(t);
                        }
                        if (trainingSelect == "p")
                        {
                            Training t = new Training("C#/.Net", 2.99);
                            Console.WriteLine("Training module added!");
                            trainingArray.Add(t);
                        }
                        if (trainingSelect == "f")
                        {
                            Bear bear = new Bear(trainingArray);
                            Console.WriteLine($"Training assigned to Bear #{counter+1}");
                            bearList.Add(bear);

                            trainingArray = new HashSet <Training>();
                            counter++;
                        }
                        else
                        {
                            Console.WriteLine("Please use one of the listed inputs");
                        }
                    }

                    Order currentOrder = new Order(bearList);
                    int   q            = bearList[0].upgrades.Count();


                    currentOrder.CustomerID = cID;

                    bool locationhandling = false;
                    while (!locationhandling)
                    {
                        Console.WriteLine("Please input one of the following location IDs");
                        PrintLocations(dbContext);
                        int lID = Convert.ToInt32(Console.ReadLine());



                        Location orderLocation = RetrieveLocation(dbContext, lID);
                        currentOrder = orderLocation.ProcessOrder(currentOrder);
                        if (currentOrder.Price == null)
                        {
                            Console.WriteLine("Please try another location.");
                        }
                        else
                        {
                            AddOrder(dbContext, currentOrder);
                            UpdateLocation(dbContext, currentOrder);
                            UpdateCustomer(dbContext, currentOrder);
                            locationhandling = !locationhandling;
                        }
                    }
                }
                else if (input == "a")
                {
                    Console.WriteLine("r:\tView a location's order history.");
                    Console.WriteLine("a:\tView a customer's order history.");
                    var inputL = Console.ReadLine();
                    if (inputL == "a")
                    {
                        Console.WriteLine("Please input the first or last name of the customer");
                        string cname = Console.ReadLine();
                        foreach (Customer customer in RetrieveCustomers(dbContext, cname))
                        {
                        }
                        ;
                    }
                    Console.WriteLine("Input the target ID:");
                    int ordersearchid = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine();
                    Console.WriteLine("Sort by:");
                    Console.WriteLine("r:\tCheapest");
                    Console.WriteLine("a:\tMost Expensive");
                    Console.WriteLine("s:\tEarliest");
                    Console.WriteLine("t:\tLatest");
                    var inputL2 = Console.ReadLine();
                    if (inputL == "r")
                    {
                        if (inputL2 == "r")
                        {
                            PrintOrdersByLocation(dbContext, ordersearchid, "price");
                        }
                        if (inputL2 == "a")
                        {
                            PrintOrdersByLocation(dbContext, ordersearchid, "price-r");
                        }
                        if (inputL2 == "s")
                        {
                            PrintOrdersByLocation(dbContext, ordersearchid, "time");
                        }
                        if (inputL2 == "t")
                        {
                            PrintOrdersByLocation(dbContext, ordersearchid, "time-r");
                        }
                    }
                    if (inputL == "a")
                    {
                        if (inputL2 == "r")
                        {
                            PrintOrdersByCustomer(dbContext, ordersearchid, "price");
                        }
                        if (inputL2 == "a")
                        {
                            PrintOrdersByCustomer(dbContext, ordersearchid, "price-r");
                        }
                        if (inputL2 == "s")
                        {
                            PrintOrdersByCustomer(dbContext, ordersearchid, "time");
                        }
                        if (inputL2 == "t")
                        {
                            PrintOrdersByCustomer(dbContext, ordersearchid, "time-r");
                        }
                    }
                }
                else if (input == "q")
                {
                    Console.WriteLine("Exiting Business Bears...");
                    running = false;
                }
                else
                {
                    Console.WriteLine("Please input a valid value\n");
                }
            }
        }