예제 #1
0
        public void CoursesMenu()
        {
            Console.Clear();
            Console.WriteLine("Select an option from Courses menu: ");
            Console.Write("0.Back to Main Menu\n1.Insert\n2.Display\n3.Exit\n\n------\n>");
            int temp = Integer(0, 3);

            switch (temp)
            {
            case 0:
            {
                MainMenu();
                break;
            }

            case 1:
            {
                new CourseService().Create();
                Console.Write("Press any button to continue...");
                Console.ReadKey();
                MainMenu();
                break;
            }

            case 2:
            {
                Console.Clear();
                List <Course> courses    = new CourseService().GetList();
                CourseView    courseView = new CourseView();
                courseView.Display(courses);
                Console.Write("If you want more info about each course please type its id:\nPress 0 to go back\n\n------\n>");
                temp = IntegerId <Course>(courses);
                if (temp != 0)
                {
                    courses = new CourseService().GetListAnalytic(courses);
                }
                while (temp != 0)
                {
                    Course course = courses.FirstOrDefault(x => x.CourseId == temp);
                    courseView.DisplayById(course);
                    Console.WriteLine("Press any button to continue...");
                    Console.ReadKey();
                    Console.Clear();
                    courseView.Display(courses);
                    Console.Write("If you want more info about each course please type its id:\nPress 0 to go back\n\n------\n>");
                    temp = IntegerId <Course>(courses);
                }
                CoursesMenu();
                break;
            }

            case 3:
            {
                Console.WriteLine("Are you sure want to close the program? <Y> or <N>?");
                if (Console.ReadKey(true).Key == ConsoleKey.Y)
                {
                    Console.WriteLine("\nExiting...\n");
                    break;
                }
                else
                {
                    Console.Clear();
                    CoursesMenu();
                    break;
                }
            }
            }
        }