Example #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;
                }
            }
        }
Example #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);
 }
Example #3
0
 /// <summary>
 /// Prints out all the list items in this list menu.
 /// </summary>
 /// <param name="title">The title of this list menu.</param>
 protected void PrintListMenu(string title)
 {
     Console.Clear();
     CliPrinter.Title(title);
     foreach (var entry in this.ListMenuOptions)
     {
         if (entry.Name == null)
         {
             Console.Write("\n");
         }
         else
         {
             Console.WriteLine($"{(char)entry.Key}.  {entry.Name}");
         }
     }
 }
Example #4
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();
 }