Beispiel #1
0
        public void AssignmentsMenu()
        {
            Console.Clear();
            Console.WriteLine("Select an option from Assignments 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:
            {
                Console.Clear();
                Console.WriteLine("Select an option from Insert menu: ");
                Console.Write("0.Back to Main Menu\n1.Create new Assignment" +
                              "\n2.Assign an Assignment to a course" +
                              "\n3.Assign an Assignment to a student" +
                              "\n4.Exit\n\n------\n>");
                int temp1 = Integer(0, 3);
                switch (temp1)
                {
                case 0: { MainMenu(); break; }

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

                case 2:
                {
                    Console.Clear();
                    List <Assignment> assignments    = new AssignmentService().SetList();
                    AssignmentView    assignmentView = new AssignmentView();
                    assignmentView.Display(assignments);
                    do
                    {
                        Console.Write("Choose an assignment id to insert in a course:\nPress 0 to go back\n\n------\n>");
                        temp = IntegerId <Assignment>(assignments);
                        if (temp == 0)
                        {
                            Console.WriteLine("Process Terminated"); MainMenu();
                        }

                        Assignment assignment = assignments.FirstOrDefault(x => x.AssignmentId == temp);
                        Console.Clear();
                        new Course_Assignment().InsertCourseByAssignment(assignment);
                        Console.Write("Do you want to add other assignment to other course?:<Y> or <N>?:\n>");
                    } while (YesOrNo());
                    MainMenu();
                    break;
                }

                case 3:
                {
                    Console.Clear();
                    List <Assignment> assignments    = new AssignmentService().SetList();
                    AssignmentView    assignmentView = new AssignmentView();
                    assignmentView.Display(assignments);
                    do
                    {
                        Console.Write("Choose an assignment id to insert in a student:\nPress 0 to go back\n\n------\n>");
                        IntegerId <Assignment>(assignments);
                        if (temp == 0)
                        {
                            Console.WriteLine("Process Terminated"); MainMenu();
                        }
                        Assignment assignment = assignments.FirstOrDefault(x => x.AssignmentId == temp);
                        Console.Clear();
                        new Grade().InsertAssignmentPerCoursePerStudent(assignment);
                        Console.Write("Do you want to add other assignment to other student?:<Y> or <N>?:\n>");
                    } while (YesOrNo());
                    Console.ReadLine();
                    MainMenu();
                    break;
                }



                case 4:
                {
                    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();
                        StudentsMenu();
                        break;
                    }
                }
                }
                break;
            }

            case 2:
            {
                Console.Clear();
                List <Assignment> assignments    = new AssignmentService().SetList();
                AssignmentView    assignmentView = new AssignmentView();
                assignmentView.Display(assignments);
                Console.Write("If you want more info about each assignment please type its id:\nPress 0 to go back\n\n------\n>");
                temp = IntegerId <Assignment>(assignments);
                if (temp != 0)
                {
                    assignments = new AssignmentService().SetListAnalytic(assignments);
                }
                while (temp != 0)
                {
                    Assignment assignment = assignments.FirstOrDefault(x => x.AssignmentId == temp);
                    assignmentView.DisplayById(assignment);
                    Console.Write("Press any button to continue...");
                    Console.ReadKey();
                    Console.Clear();
                    assignmentView.Display(assignments);
                    Console.Write("If you want more info about each assignmnet please type its id:\nPress 0 to go back\n\n------\n>");
                    temp = IntegerId <Assignment>(assignments);
                }
                MainMenu();
                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();
                    AssignmentsMenu();
                    break;
                }
            }
            }
        }