Ejemplo n.º 1
0
        /// <summary>
        /// Starts the menu loop.
        /// </summary>
        public void Run()
        {
            try
            {
                Push(new StoreCliMenu.Main(this.AppState));
            }
            catch (Exception)
            {
                CliPrinter.Error("An error occurred while connecting to database. Please try running the program again.");
                return;
            }

            while (this.Menus.Count > 0)
            {
                try
                {
                    this.Menus.Peek().PrintMenu();
                    this.Menus.Peek().InputLoop();
                }
                catch (Exception)
                {
                    CliInput.PressAnyKey("\nAn error occurred while processing your request. Returning.");
                    this.Pop();
                    continue;
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Validates an email address.
 /// </summary>
 /// <param name="email">The email to validate.</param>
 /// <returns>Whether the provided text is in an email address format.</returns>
 public static bool EmailValidator(string email)
 {
     if (!StoreDb.Customer.ValidateEmail(email))
     {
         CliPrinter.Error("Please enter a valid email address.");
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Prints an error message then waits for the user to confirm, after which
 /// the menu will be taken off the menu stack causing navigation to back one menu.
 /// </summary>
 /// <param name="menu">The current menu.</param>
 /// <param name="message">Message to print to the user.</param>
 public static void AbortThenExit(this CliMenu menu, string message)
 {
     CliPrinter.Error(message);
     CliInput.PressAnyKey();
     menu.MenuExit();
 }