Exemplo n.º 1
0
        /// <summary>
        /// The main method for running the application.
        /// </summary>
        public void Run()
        {
            //bool isFirstRun = true;
            Console.CancelKeyPress += new ConsoleCancelEventHandler(ControlCHandler);

            _view.ShowWelcomeScreen();
            _view.ShowMainMenu();

            AdminCommand command;

            while (true)
            {
                //Console.Clear();
                //if (isFirstRun)
                //{
                //    _view.ShowWelcomeScreen();
                //    _view.ShowMainMenu();
                //    isFirstRun = false;
                //} else
                //{
                //    Console.WriteLine(TextProcessor.LOGO);
                //}

                // TODO Improve usability by clearng console every loop Console.Clear();
                if (_repository == null)
                {
                    Console.Clear();
                    Console.WriteLine("Repository is null\t\tWARNING!");
                    break;
                }
                if (_view == null)
                {
                    Console.Clear();
                    Console.WriteLine("View is null\t\tWARNING!");
                    break;
                }


                _view.ShowPrompt();
                string input = Console.ReadLine();
                command = CommandFactory.GetCommand(input);
                command.Invoke(_repository, _view);
            }
        }
 /// <summary>
 /// Starts a view showing a help menu (or possible commands).
 /// </summary>
 /// <param name="db">Optional location of database in case extra information needs to be shown.</param>
 /// <param name="view">The view on which the help information should be shown.</param>
 internal static void Help(IRepository <User> db, IAdminView view)
 {
     view.ShowMainMenu();
 }