Ejemplo n.º 1
0
 private static void ExecuteLecturer(LecturerInvoker invoker, ICommand command)
 {
     invoker.SetCommand(command);
     invoker.Invoke();
 }
Ejemplo n.º 2
0
        static void ShowSubMenuLecturerManagement()
        {
            string userChoose = String.Empty;

            Console.Clear();
            do
            {
                // Sub menu Lecturer Management
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("====LECTURER MANAGEMENT MENU===");
                Console.WriteLine("===============================");
                Console.WriteLine("1. Add new Lecturer");
                Console.WriteLine("2. View all Lecturers");
                Console.WriteLine("3. Search Lecturer");
                Console.WriteLine("4. Delete Lecturer");
                Console.WriteLine("5. Update Lecturer");
                Console.WriteLine("6. Back to main menu");
                Console.WriteLine("===============================");

                // User choose
                Console.BackgroundColor = ConsoleColor.Red;
                Console.Write("Please choose: ");
                userChoose = Console.ReadLine();
                Console.ResetColor();

                // Initialize command
                LecturerReceiver lecturerReciever = new LecturerReceiver(Program.ListLecturers);
                LecturerInvoker  lecturerInvoker  = new LecturerInvoker();

                switch (userChoose)
                {
                case "1":     // Add new Lecturer menu
                              // Create new object Lecturer
                    ExecuteLecturer(lecturerInvoker, new LecturerCommand(lecturerReciever, CommandAction.Add));
                    break;

                case "2":     // View all Lecturers menu
                              // Empty list -> show waring message
                    ExecuteLecturer(lecturerInvoker, new LecturerCommand(lecturerReciever, CommandAction.ViewAll));
                    break;

                case "3":     // Search Lecturer menu
                              // Empty list -> show waring message
                    ExecuteLecturer(lecturerInvoker, new LecturerCommand(lecturerReciever, CommandAction.Search));
                    break;

                case "4":     // Delete Lecturer menu
                              // Empty list -> show waring message
                    ExecuteLecturer(lecturerInvoker, new LecturerCommand(lecturerReciever, CommandAction.Delete));
                    break;

                case "5":     // Update Lecturer menu
                              // Empty list -> show waring message
                    ExecuteLecturer(lecturerInvoker, new LecturerCommand(lecturerReciever, CommandAction.Update));
                    break;

                case "6":     // Back to main menu
                    ShowMainMenu();
                    break;

                default:
                    Console.WriteLine("Not correct command. Please input only number (1, 2, 3, 4, 5 or 6)");
                    ShowSubMenuStudentManagement();
                    break;
                }
            } while (userChoose != "6");
        }