public static void AddAssignmentInCourse() { Console.Clear(); AssignmentDb aDB = new AssignmentDb(); CourseDb cDB = new CourseDb(); List <Course> courses = cDB.GetCourses(); List <Assignment> assignments = aDB.GetAssignments(); if (courses.Count != 0 && assignments.Count != 0) { Console.WriteLine("Select an assignment to add by using its number on the list: \n"); ShowLists.ShowList(assignments, "Students"); bool result = Int32.TryParse(Console.ReadLine(), out int assignmentID); while (!result || (assignmentID < 1 || assignmentID > assignments.Count)) { Console.Write($"Wrong input! Please select using numbers from 1 to {assignments.Count} "); result = Int32.TryParse(Console.ReadLine(), out assignmentID); } Console.Clear(); Console.WriteLine("Select a course by using its number on the list: \n"); ShowLists.ShowList(courses, "Courses"); result = Int32.TryParse(Console.ReadLine(), out int courseID); while (!result || (courseID < 1 || courseID > courses.Count)) { Console.Write($"Wrong input! Please select using numbers from 1 to {courses.Count} "); result = Int32.TryParse(Console.ReadLine(), out courseID); } Console.Clear(); AssignmentsPerCourseDb.AddAssignmentToCourse(assignmentID, courseID); Console.WriteLine("Assignment added successfully to Course!"); } else { Console.WriteLine("There aren't neither Students nor Courses yet"); } }
public static void AddStudentInCourse() { Console.Clear(); StudentDb sDB = new StudentDb(); CourseDb cDB = new CourseDb(); List <Course> courses = cDB.GetCourses(); List <Student> students = sDB.GetStudents(); if (courses.Count != 0 && students.Count != 0) { Console.WriteLine("Select a student to add by using its number on the list: \n"); ShowLists.ShowList(students, "Students"); bool result = Int32.TryParse(Console.ReadLine(), out int studentID); while (!result || (studentID < 1 || studentID > students.Count)) { Console.Write($"Wrong input! Please select using numbers from 1 to {students.Count} "); result = Int32.TryParse(Console.ReadLine(), out studentID); } Console.Clear(); Console.WriteLine("Select a course by using its number on the list: \n"); ShowLists.ShowList(courses, "Courses"); result = Int32.TryParse(Console.ReadLine(), out int courseID); while (!result || (courseID < 1 || courseID > courses.Count)) { Console.Write($"Wrong input! Please select using numbers from 1 to {courses.Count} "); result = Int32.TryParse(Console.ReadLine(), out courseID); } Console.Clear(); StudentsPerCourseDb.AddStudentToCourse(studentID, courseID); Console.WriteLine("Student enrolled to course successfully!"); } else { Console.WriteLine("There aren no Students or Courses yet"); } }
public static void AddTrainerInCourse() { Console.Clear(); TrainerDb tDB = new TrainerDb(); CourseDb cDB = new CourseDb(); List <Course> courses = cDB.GetCourses(); List <Trainer> trainers = tDB.GetTrainers(); if (courses.Count != 0 && trainers.Count != 0) { Console.WriteLine("Select a trainer to add by using its number on the list: \n"); ShowLists.ShowList(trainers, "Trainers"); bool result = Int32.TryParse(Console.ReadLine(), out int trainerID); while (!result || (trainerID < 1 || trainerID > trainers.Count)) { Console.Write($"Wrong input! Please select using numbers from 1 to {trainers.Count} "); result = Int32.TryParse(Console.ReadLine(), out trainerID); } Console.Clear(); Console.WriteLine("Select a course by using its number on the list: \n"); ShowLists.ShowList(courses, "Courses"); result = Int32.TryParse(Console.ReadLine(), out int courseID); while (!result || (courseID < 1 || courseID > courses.Count)) { Console.Write($"Wrong input! Please select using numbers from 1 to {courses.Count} "); result = Int32.TryParse(Console.ReadLine(), out courseID); } Console.Clear(); TrainersPerCourseDb.AddTrainerToCourse(trainerID, courseID); Console.WriteLine("Trainer added to course successfully!"); } else { Console.WriteLine("There aren no Trainers or Courses yet"); } }
public static void AddAssignmentToStudent() { Console.Clear(); AssignmentDb aDB = new AssignmentDb(); StudentDb sDB = new StudentDb(); List<Assignment> assignments = aDB.GetAssignments(); List<Student> students = sDB.GetStudents(); if (assignments.Count != 0 && students.Count != 0) { Console.WriteLine("Select an assignment by using its number on the list: \n"); ShowLists.ShowList(assignments, "Assignments"); bool result = Int32.TryParse(Console.ReadLine(), out int assignmentID); while (!result || (assignmentID < 1 || assignmentID > assignments.Count)) { Console.Write($"Wrong input! Please select using numbers from 1 to {assignments.Count} "); result = Int32.TryParse(Console.ReadLine(), out assignmentID); } Console.WriteLine("Select a student to add by using its number on the list: \n"); ShowLists.ShowList(students, "Students"); result = Int32.TryParse(Console.ReadLine(), out int studentID); while (!result || (studentID < 1 || studentID > students.Count)) { Console.Write($"Wrong input! Please select using numbers from 1 to {students.Count} "); result = Int32.TryParse(Console.ReadLine(), out studentID); } Console.Clear(); AssignmentsPerStudentDb.AddΑssignmentToStudent(assignmentID, studentID); Console.WriteLine("Assignment added to Student successfully!"); } else Console.WriteLine("There aren no Students or Assignments yet"); }