Exemplo n.º 1
0
 /// <summary>
 /// Adds methods to <c>CommandsMain</c> which the user will have access to in the main menu.
 /// </summary>
 public void GetCommandsMain()
 {
     CommandsMain.Add(LogOut);
     CommandsMain.Add(ViewProfile);
     CommandsMain.Add(ViewOrderHistory);
     CommandsMain.Add(ViewLocations);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Displays commands from <c>CommandsMain</c> or <CommandsLocation</c>.
        /// Used in the the <c>UserTerminal</c> Run method loop.
        /// Depends on the state of the Location field.
        /// null => display main menu.
        /// <c>Location</c> instance => display location menu.
        /// </summary>
        public void DisplayCommands()
        {
            //Location is null when user is in the main menu.
            if (UI.Location == null)
            {
                Console.WriteLine("Main Menu:\n");
                for (int i = 0; i < CommandsMain.Count; i++)
                {
                    Console.WriteLine($"{i}:\t{CommandsMain[i].Method.Name}");
                }
                Console.Write("\n> ");
                try
                {
                    //Console command input.
                    int input = Int32.Parse(Console.ReadLine());
                    Console.Clear();
                    CommandsMain[input]();
                }
                catch (System.Exception)
                {
                    CommandError();
                }
            }

            //Location is not null. Display the location menu instead.
            else
            {
                CurrentLocation();
                for (int i = 0; i < CommandsLocation.Count; i++)
                {
                    Console.WriteLine($"{i}:\t{CommandsLocation[i].Method.Name}");
                }
                Console.Write("\n> ");
                try
                {
                    //Console command input.
                    int input = Int32.Parse(Console.ReadLine());
                    Console.Clear();
                    CommandsLocation[input]();
                }
                catch (System.Exception)
                {
                    CommandError();
                }
            }
        }
 /// <summary>
 /// Adds methods to <c>CommandsMain</c> which the user will have access to in the main menu.
 /// Adds the admin commands to the <c>CommandsMain</c>.
 /// </summary>
 public new void GetCommandsMain()
 {
     CommandsMain.Add(SearchCustomer);
     CommandsMain.Add(AddAdmin);
     CommandsMain.Add(AddCustomer);
     CommandsMain.Add(AddLocation);
     CommandsMain.Add(RemoveLocation);
 }