// assignments courses

        private static void ConnectAssignmentsCourses()
        {
            if (AssignmentList.Count == 0)
            {
                Console.WriteLine("assignments do not exist\n");
                return;
            }
            else if (CourseList.Count == 0)
            {
                Console.WriteLine("courses do not exist\n");
                return;
            }

            AssignmentManager.ShowAssignments(false);

            CourseManager.ShowCourses(false);

            string input;
            bool   correctInput;

            while (true)
            {
                Console.WriteLine("type the number of assignment and course you want to connect, using -");
                Console.WriteLine("for example type '1-2' to connect the first assignment with the second course");
                Console.WriteLine("type '0' or 'exit' to leave\n");

                input = Console.ReadLine();
                if (input.Trim().Equals("0") || input.Trim().Equals("exit"))
                {
                    break;
                }

                string[] items = input.Split('-');
                if (items.Length < 2)
                {
                    Console.WriteLine("arguments missing");
                    continue;
                }
                else if (items.Length > 2)
                {
                    Console.WriteLine("too many arguments\n");
                    continue;
                }

                correctInput = Int32.TryParse(items[0].Trim(), out int AssignmentCode);
                if (!correctInput)
                {
                    Console.WriteLine("wrong assignment attribute\n");
                    continue;
                }

                correctInput = Int32.TryParse(items[1].Trim(), out int CourseCode);
                if (!correctInput)
                {
                    Console.WriteLine("wrong course attribute\n");
                    continue;
                }

                if (AssignmentCode < 1 || AssignmentCode > AssignmentList.Count)
                {
                    Console.WriteLine("assignment number is not valid");
                    continue;
                }
                if (CourseCode < 1 || CourseCode > CourseList.Count)
                {
                    Console.WriteLine("course number is not valid");
                    continue;
                }

                Assignment a = AssignmentList[AssignmentCode - 1];
                Course     c = CourseList[CourseCode - 1];

                if (a.CourseCodes.Contains(CourseCode - 1) && c.AssignmentCodes.Contains(AssignmentCode - 1))
                {
                    Console.WriteLine("this relation already exists");
                    continue;
                }

                a.CourseCodes.Add(CourseCode - 1);
                c.AssignmentCodes.Add(AssignmentCode - 1);

                Console.WriteLine($"you connected assignment {AssignmentCode}: {a.Title} with course {CourseCode}: {c.Title}\n");
            }
        }
        // assignments student

        private static void ConnectAssignmentsStudents()
        {
            if (AssignmentList.Count == 0)
            {
                Console.WriteLine("assignments do not exist\n");
                return;
            }
            else if (CourseList.Count == 0)
            {
                Console.WriteLine("courses do not exist\n");
                return;
            }
            else if (StudentList.Count == 0)
            {
                Console.WriteLine("students do not exist\n");
                return;
            }

            AssignmentManager.ShowAssignments(false);

            CourseManager.ShowCourses(false);

            StudentManager.ShowStudents(false);

            string input;
            bool   correctInput;

            while (true)
            {
                Console.WriteLine("type the number of assignment,course and student you want to connect, using -");
                Console.WriteLine("for example type '1-2-3' to connect the first assignment with the second course for the third student");
                Console.WriteLine("student and assignment must already be connected to course");
                Console.WriteLine("type '0' or 'exit' to leave\n");

                input = Console.ReadLine();
                if (input.Trim().Equals("0") || input.Trim().Equals("exit"))
                {
                    break;
                }

                string[] items = input.Split('-');
                if (items.Length < 3)
                {
                    Console.WriteLine("arguments missing\n");
                    continue;
                }
                else if (items.Length > 3)
                {
                    Console.WriteLine("too many arguments\n");
                    continue;
                }

                correctInput = Int32.TryParse(items[0].Trim(), out int AssignmentCode);
                if (!correctInput)
                {
                    Console.WriteLine("wrong assignment attribute\n");
                    continue;
                }

                correctInput = Int32.TryParse(items[1].Trim(), out int CourseCode);
                if (!correctInput)
                {
                    Console.WriteLine("wrong course attribute\n");
                    continue;
                }

                correctInput = Int32.TryParse(items[2].Trim(), out int StudentCode);
                if (!correctInput)
                {
                    Console.WriteLine("wrong student attribute\n");
                    continue;
                }

                //check codes are correct

                if (CourseCode > CourseList.Count || CourseCode < 1)
                {
                    Console.WriteLine("course number is not valid\n");
                    continue;
                }
                else if (AssignmentCode > AssignmentList.Count || AssignmentCode < 1)
                {
                    Console.WriteLine("assignment number is not valid\n");
                    continue;
                }
                else if (StudentCode > StudentList.Count || StudentCode < 1)
                {
                    Console.WriteLine("student number is not valid\n");
                    continue;
                }


                Course     c = CourseList[CourseCode - 1];
                Assignment a = AssignmentList[AssignmentCode - 1];
                Student    s = StudentList[StudentCode - 1];

                //check course has assignment

                bool CourseHasAssignment = c.AssignmentCodes.Contains(AssignmentCode - 1);
                if (!CourseHasAssignment)
                {
                    Console.WriteLine($"Course '{c.Title}' doesn't have assignment '{a.Title}'\n");
                    continue;
                }

                //check assignment has course

                bool AssignmentHasCourse = a.CourseCodes.Contains(CourseCode - 1);
                if (!AssignmentHasCourse)
                {
                    Console.WriteLine($"Assignment '{c.Title}' doesn't belong to course '{c.Title}'\n");
                    continue;
                }

                //check course has student

                bool CourseHasStudent = c.StudentCodes.Contains(StudentCode - 1);
                if (!CourseHasStudent)
                {
                    Console.WriteLine($"Course '{c.Title}' doesn't have student '{s.LastName}'\n");
                    continue;
                }

                //check student has course

                bool StudentHasCourse = s.CourseCodes.Contains(CourseCode - 1);
                if (!StudentHasCourse)
                {
                    Console.WriteLine($"Student '{s.LastName}' doesn't belong to course '{c.Title}'\n");
                    continue;
                }

                //add them

                if (s.AssignmentCodes.Contains(AssignmentCode - 1) && a.StudentCodes.Contains(StudentCode - 1))
                {
                    Console.WriteLine("this relation already exists\n");
                    continue;
                }

                s.AssignmentCodes.Add(AssignmentCode - 1);
                a.StudentCodes.Add(StudentCode - 1);

                Console.Write($"you connected assignment {AssignmentCode}: '{a.Title}'");
                Console.WriteLine($"with course {CourseCode}: '{c.Title}' ");
                Console.WriteLine($"for student {StudentCode}: '{s.FirstName} {s.LastName}'\n");
            }
        }
        // trainers courses

        private static void ConnectTrainersCourses()
        {
            if (TrainerList.Count == 0)
            {
                Console.WriteLine("trainers do not exist\n");
                return;
            }
            else if (CourseList.Count == 0)
            {
                Console.WriteLine("courses do not exist\n");
                return;
            }

            TrainerManager.ShowTrainers(false);

            CourseManager.ShowCourses(false);

            string input;
            bool   correctInput;

            while (true)
            {
                Console.WriteLine("type the number of trainer and course you want to connect, using -");
                Console.WriteLine("for example type '1-2' to connect the first trainer with the second course");
                Console.WriteLine("type '0' or 'exit' to leave\n");

                input = Console.ReadLine();
                if (input.Trim().Equals("0") || input.Trim().Equals("exit"))
                {
                    break;
                }

                string[] items = input.Split('-');
                if (items.Length < 2)
                {
                    Console.WriteLine("arguments missing\n");
                }
                else if (items.Length > 2)
                {
                    Console.WriteLine("too many arguments\n");
                    continue;
                }

                correctInput = Int32.TryParse(items[0].Trim(), out int TrainerCode);
                if (!correctInput)
                {
                    Console.WriteLine("wrong trainer attribute\n");
                    continue;
                }

                correctInput = Int32.TryParse(items[1].Trim(), out int CourseCode);
                if (!correctInput)
                {
                    Console.WriteLine("wrong course attribute\n");
                    continue;
                }

                if (TrainerCode < 1 || TrainerCode > TrainerList.Count)
                {
                    Console.WriteLine("trainer number is not valid\n");
                    continue;
                }
                if (CourseCode < 1 || CourseCode > CourseList.Count)
                {
                    Console.WriteLine("course number is not valid\n");
                    continue;
                }

                Trainer t = TrainerList[TrainerCode - 1];
                Course  c = CourseList[CourseCode - 1];

                if (t.CourseCodes.Contains(CourseCode - 1) && c.TrainerCodes.Contains(TrainerCode - 1))
                {
                    Console.WriteLine("this relation already exists\n");
                    continue;
                }

                t.CourseCodes.Add(CourseCode - 1);
                c.TrainerCodes.Add(TrainerCode - 1);

                Console.WriteLine($"you connected trainer {TrainerCode}: {t.FirstName} {t.LastName} with course {CourseCode}: {c.Title}\n");
            }
        }