Beispiel #1
0
        ///<summary>Method to View Inventory of Chosen Location by passing business logic location object to data handler</summary>
        private void ViewLocationInventory()
        {
            LocationHandler lh        = new LocationHandler();
            List <Location> locations = lh.GetLocations();
            int             i         = 0;

            foreach (Location l in locations)
            {
                Console.WriteLine($" [{i}] {l.BranchName}");
                i++;
            }
            string input;

            do
            {
                Console.WriteLine("Choose Branch");
                input = Console.ReadLine();
            } while (ErrorHandler.InvalidIntInput(input));
            try
            {
                List <Inventory> storeInventory = lh.GetInventory(locations[int.Parse(input)]);
                foreach (Inventory inv in storeInventory)
                {
                    Console.WriteLine("Product: " + inv.Prod.Name + " \n Stock: " + inv.Stock);
                }
                Log.Information($"Viewed inventory of {locations[int.Parse(input)].BranchName}");
                Menu();
            }
            catch (IndexOutOfRangeException ex)
            {
                Console.WriteLine(ex.Message);
                Log.Error(ex.Message);
                ViewLocationInventory();
            }
        }
        public void Ordermenu(Customer c)
        {
            //generate order menu
            OrderHandler    oh   = new OrderHandler();
            Customer        cust = c;
            CustomerHandler ch   = new CustomerHandler();
            LocationHandler lh   = new LocationHandler();
            //gets the store locations in the same city or state
            List <string> nearLoc = lh.GetNearestStore(c.CustAddress);

            Console.WriteLine(@"There are {nearLoc.length} near you \n please choose branch name");
            int ctr = 0;

            foreach (string s in nearLoc)
            {
                Console.WriteLine(ctr + " " + s);
            }
            Console.WriteLine("Please input which branch you'd like to shop from: ");
            int      input  = int.Parse(Console.ReadLine());
            Location choice = new Location()
            {
                BranchName     = nearLoc[input],
                StoreAddress   = lh.GetAddress(nearLoc[input]),
                StoreInventory = lh.GetInventory(nearLoc[input])
            };

            Console.WriteLine("Welcome to the " + nearLoc[input] + " branch \n What would you like to buy?");
            //Add code to print out inventory and to take orders
            //Use orderHandler
            //After taking orders create new order object
            Order custorder = new Order()
            {
                Cust = c,
                Num  = 0,
                Prod = null,
                Stor = choice
            };

            Console.WriteLine("Finished Ordering? \n Y^(Yes) N^(No)");
            CheckOut chck = new CheckOut();

            chck.CheckOutMenu(c, choice, custorder);
        }