public List <TrainersPerCourse> GetTrainersPerCourse() { List <TrainersPerCourse> trainersPerCourse = new List <TrainersPerCourse>(); try { using (SqlConnection con = new SqlConnection(conString)) { string queryString = "select Course.title as [Course], firstName as [First name], lastName as [Last name] from Trainer " + "inner join TrainerCourse " + "on Trainer.Tid = TrainerCourse.Tid " + "inner join Course on Course.Cid = TrainerCourse.Cid " + "group by title, firstName, lastName"; con.Open(); SqlCommand cmd = new SqlCommand(queryString, con); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { TrainersPerCourse tpc = new TrainersPerCourse(courseTitle: reader[0].ToString(), firstName: reader[1].ToString(), lastName: reader[2].ToString()); trainersPerCourse.Add(tpc); } } } catch (Exception) { Console.WriteLine("Something went wrong Code: S_S_GTPC"); } return(trainersPerCourse); }
public List <TrainersPerCourse> AllTrainersPerAllCourses() { List <Course> courses = GetAll(); List <Trainer> trainers = new TrainerService().GetAll(); List <TrainerCourse> teaches = new TrainerCourseService().GetAll(); var querySql = from tr in trainers join te in teaches on tr.TrainerId equals te.TrainerId join c in courses on te.CourseId equals c.CourseId select new { Trainer = tr, Course = c }; List <TrainersPerCourse> allTrainersPerAllCourses = new List <TrainersPerCourse>(); var groupedByCourses = querySql.GroupBy(g => g.Course); foreach (var group in groupedByCourses) { TrainersPerCourse trainersPerCourse = new TrainersPerCourse(); trainersPerCourse.Course = group.Key; foreach (var item in group) { trainersPerCourse.Trainers.Add(item.Trainer); } allTrainersPerAllCourses.Add(trainersPerCourse); } return(allTrainersPerAllCourses); }
private static void Initialize() { //Student Data Base Student S1 = new Student("Marios", "Matthioulakis", new DateTime(1978, 11, 2), 2500M); Student S2 = new Student("Nikos", "Nikolakakis", new DateTime(1979, 9, 22), 2500M); Student S3 = new Student("Kostas", "Konsta", new DateTime(1981, 5, 20), 2500M); Student S4 = new Student("Vassilis", "Vass", new DateTime(1982, 6, 25), 2500M); Student S5 = new Student("Kostas", "pap", new DateTime(1983, 5, 20), 2500M); Student S6 = new Student("giannis", "gian", new DateTime(1983, 2, 20), 2500M); Student S7 = new Student("Alekos", "Alex", new DateTime(1983, 5, 20), 2500M); Student S8 = new Student("Spyros", "Vront", new DateTime(1983, 3, 20), 2500M); Student S9 = new Student("Aliki", "Soum", new DateTime(1983, 5, 20), 2500M); Student S10 = new Student("Maria", "Mario", new DateTime(1980, 6, 20), 2500M); studentsDB.Add(S1); studentsDB.Add(S2); studentsDB.Add(S3); studentsDB.Add(S4); studentsDB.Add(S5); studentsDB.Add(S6); studentsDB.Add(S7); studentsDB.Add(S8); studentsDB.Add(S9); studentsDB.Add(S10); //Trainers Data Base Trainer T1 = new Trainer(CourseType.CSharp, "Hector", "Gkatsos"); Trainer T2 = new Trainer(CourseType.Java, "Argyris", "Pagidas"); Trainer T3 = new Trainer(CourseType.CSharp, "Ioannis", "Panagopoulos"); Trainer T4 = new Trainer(CourseType.Java, "Mairy", "Soumi"); Trainer T5 = new Trainer(CourseType.Java, "Trainer", "Train"); Trainer T6 = new Trainer(CourseType.Java, "Dim", "Tsamis"); Trainer T7 = new Trainer(CourseType.Java, "John", "Lask"); Trainer T8 = new Trainer(CourseType.Java, "Kostas", "Xagorar"); trainersDB.Add(T1); trainersDB.Add(T2); trainersDB.Add(T3); trainersDB.Add(T4); trainersDB.Add(T5); trainersDB.Add(T6); trainersDB.Add(T7); trainersDB.Add(T8); //Assignments DB Assignment AS1 = new Assignment("Assignent1", "C#/Java blablabla...", new DateTime(2019, 03, 31, 12, 0, 0)); Assignment AS2 = new Assignment("Assignent2", "Java blablabla...", new DateTime(2019, 10, 31, 12, 0, 0)); Assignment AS3 = new Assignment("Assignent3", "Python blablabla...", new DateTime(2019, 03, 31, 12, 0, 0)); Assignment AS4 = new Assignment("Assignent4", "ASP blablabla...", new DateTime(2019, 10, 31, 12, 0, 0)); Assignment AS5 = new Assignment("Assignent5", "JS blablabla...", new DateTime(2019, 03, 31, 12, 0, 0)); Assignment AS6 = new Assignment("Assignent6", "HTML blablabla...", new DateTime(2019, 10, 31, 12, 0, 0)); Assignment AS7 = new Assignment("Assignent6", "HTML blablabla...", new DateTime(2019, 10, 31, 12, 0, 0)); Assignment AS8 = new Assignment("Assignent6", "HTML blablabla...", new DateTime(2019, 10, 31, 12, 0, 0)); assignmentsDB.Add(AS1); assignmentsDB.Add(AS2); assignmentsDB.Add(AS3); assignmentsDB.Add(AS4); assignmentsDB.Add(AS5); assignmentsDB.Add(AS6); assignmentsDB.Add(AS7); assignmentsDB.Add(AS8); //Create Courses Course FoulTimeCSharp = new Course("Full Time C#", StreamType.FullTime, CourseType.CSharp, new DateTime(2019, 01, 01), new DateTime(2019, 03, 31)); Course PartTimeCSharp = new Course("Part Time C#", StreamType.PartTime, CourseType.CSharp, new DateTime(2019, 04, 01), new DateTime(2019, 10, 31)); Course FoulTimeJava = new Course("Full Time Java", StreamType.FullTime, CourseType.Java, new DateTime(2019, 01, 01), new DateTime(2019, 03, 31)); Course PartTimeJava = new Course("Part Time Java", StreamType.PartTime, CourseType.Java, new DateTime(2019, 04, 01), new DateTime(2019, 10, 31)); //List of Courses CB8.Add(FoulTimeCSharp); CB8.Add(PartTimeCSharp); CB8.Add(FoulTimeJava); CB8.Add(PartTimeJava); //Relate students to Course StudentsPerCourse CB81 = new StudentsPerCourse(FoulTimeCSharp, studentsDB.GetRange(0, 3)); StudentsPerCourse CB82 = new StudentsPerCourse(PartTimeCSharp, studentsDB.GetRange(3, 6)); StudentsPerCourse CB83 = new StudentsPerCourse(FoulTimeJava, studentsDB.GetRange(4, 5)); StudentsPerCourse CB84 = new StudentsPerCourse(PartTimeJava, studentsDB.GetRange(7, 3)); studentsPerCourse.Add(CB81); studentsPerCourse.Add(CB82); studentsPerCourse.Add(CB83); studentsPerCourse.Add(CB84); //Relate Trainers to Courses TrainersPerCourse TPC1 = new TrainersPerCourse(FoulTimeCSharp, trainersDB.GetRange(0, 2)); TrainersPerCourse TPC2 = new TrainersPerCourse(PartTimeCSharp, trainersDB.GetRange(2, 2)); TrainersPerCourse TPC3 = new TrainersPerCourse(FoulTimeJava, trainersDB.GetRange(4, 2)); TrainersPerCourse TPC4 = new TrainersPerCourse(PartTimeJava, trainersDB.GetRange(6, 2)); trainersPerCourse.Add(TPC1); trainersPerCourse.Add(TPC2); trainersPerCourse.Add(TPC3); trainersPerCourse.Add(TPC4); //Relate Assignments to Courses AssignmentsPerCours APC1 = new AssignmentsPerCours(FoulTimeCSharp, assignmentsDB.GetRange(0, 2)); AssignmentsPerCours APC2 = new AssignmentsPerCours(PartTimeCSharp, assignmentsDB.GetRange(2, 2)); AssignmentsPerCours APC3 = new AssignmentsPerCours(FoulTimeJava, assignmentsDB.GetRange(4, 2)); AssignmentsPerCours APC4 = new AssignmentsPerCours(PartTimeJava, assignmentsDB.GetRange(6, 2)); assignmentsPerCourse.Add(APC1); assignmentsPerCourse.Add(APC2); assignmentsPerCourse.Add(APC3); assignmentsPerCourse.Add(APC4); //Relate Assigments to Students and Courses AssignmentPerCourseStudents APS1 = new AssignmentPerCourseStudents(S1, APC1); AssignmentPerCourseStudents APS2 = new AssignmentPerCourseStudents(S2, APC2); AssignmentPerCourseStudents APS3 = new AssignmentPerCourseStudents(S3, APC3); AssignmentPerCourseStudents APS4 = new AssignmentPerCourseStudents(S4, APC4); AssignmentPerCourseStudents APS5 = new AssignmentPerCourseStudents(S5, APC2); AssignmentPerCourseStudents APS6 = new AssignmentPerCourseStudents(S6, APC2); AssignmentPerCourseStudents APS7 = new AssignmentPerCourseStudents(S7, APC2); AssignmentPerCourseStudents APS8 = new AssignmentPerCourseStudents(S8, APC2); AssignmentPerCourseStudents APS9 = new AssignmentPerCourseStudents(S9, APC2); AssignmentPerCourseStudents APS10 = new AssignmentPerCourseStudents(S10, APC2); assignmentPerCourseStudents.Add(APS1); assignmentPerCourseStudents.Add(APS2); assignmentPerCourseStudents.Add(APS3); assignmentPerCourseStudents.Add(APS4); assignmentPerCourseStudents.Add(APS5); assignmentPerCourseStudents.Add(APS6); assignmentPerCourseStudents.Add(APS7); assignmentPerCourseStudents.Add(APS8); assignmentPerCourseStudents.Add(APS9); assignmentPerCourseStudents.Add(APS10); }
public static void Run() { Course c1 = new Course(); Assignment a1 = new Assignment(); Trainer tr1 = new Trainer(); Student s1 = new Student(); StudentsPerCourse sPC = new StudentsPerCourse(); TrainersPerCourse tPC = new TrainersPerCourse(); AssignmentsPerCourse aPC = new AssignmentsPerCourse(); AssignmetsPerStudent aPS = new AssignmetsPerStudent(); AssignmentsPerCoursePerStudent aPCPS = new AssignmentsPerCoursePerStudent(); StudentsWithMoreThanOneCourse sMTOC = new StudentsWithMoreThanOneCourse(); ServiceGet serviseGet = new ServiceGet(); ServiceInsert serviseInsert = new ServiceInsert(); ServiceCheck serviceCheck = new ServiceCheck(); string userInput2 = "", userInput3 = "", userInput5 = ""; int selectCourse; do { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); Console.WriteLine("\tWellcome to Private School! What would you like to do?"); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\t0. Exit."); Console.WriteLine("\t1. Course."); Console.WriteLine("\t2. Assignment."); Console.WriteLine("\t3. Trainer."); Console.WriteLine("\t4. Student."); Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : "); userInput2 = Console.ReadLine(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n\t=================================================================================\n"); Console.ForegroundColor = ConsoleColor.White; //UserInput2 = 1, normal mode, Course-------------------------------------------------------------------------------------------------------------------- if (userInput2 == "1") { do { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); Console.WriteLine("\tYou are in the course mode! What would you like to do?"); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\t0. Exit."); Console.WriteLine("\t1. New course."); Console.WriteLine("\t2. Output list with all courses."); Console.WriteLine("\t3. Add students at courses."); Console.WriteLine("\t4. Output students per course."); Console.WriteLine("\t5. Add trainers at courses."); Console.WriteLine("\t6. Output trainers per course."); Console.WriteLine("\t7. Add assignments at courses."); Console.WriteLine("\t8. Output assignments per course."); Console.WriteLine("\t9. Go back."); Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : "); userInput3 = Console.ReadLine(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n\t=================================================================================\n"); Console.ForegroundColor = ConsoleColor.White; //UserInput3 = 1, normal mode, New course------------------------------------------------------------------------------------------------------- if (userInput3 == "1") { serviseInsert.InsertCourse(); } //UserInput3 = 2, normal mode, List of courses------------------------------------------------------------------------------------------------------- else if (userInput3 == "2") { c1.ListOfCoursecOutput(serviseGet.GetAllCourses()); MyStaticClass.PressKeyToContinue(); } //UserInput3 = 3, normal mode, Add students at courses------------------------------------------------------------------------------------------------------- else if (userInput3 == "3") { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); Console.WriteLine("\tSelect the number of course that you want to add students."); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; List <Course> allCourses = serviseGet.GetAllCourses(); c1.ListOfCoursecOutput(allCourses); Console.WriteLine(); do { Console.Write("\tEnter the apropriate number : "); selectCourse = MyStaticClass.InputTryToConvertToInt(); } while (selectCourse <= 0 || selectCourse > allCourses.Count); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n\t=================================================================================\n"); Console.ForegroundColor = ConsoleColor.White; do { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\tSelect how you want to add a student."); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(); Console.WriteLine("\t1. Add a new student."); Console.WriteLine("\t2. Add an excisting student."); Console.WriteLine("\t9. Go back."); Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : "); userInput5 = Console.ReadLine(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n\t=================================================================================\n"); Console.ForegroundColor = ConsoleColor.White; if (userInput5 == "1") { serviseInsert.InsertStudent(); List <Student> students = serviseGet.GetAllStudents(); serviseInsert.InsertStudentAtCourse((int)students[students.Count - 1].Sid, (int)allCourses[selectCourse - 1].Cid); } else if (userInput5 == "2") { string addAnotherStudentfromList; bool notSuccededAdd = true; do { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); Console.WriteLine("\tSelect the number of student."); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; List <Student> allStudents = serviseGet.GetAllStudents(); s1.ListOfStudentsOutput(allStudents); do { int userSelectStudent = 0; try { Console.WriteLine(); Console.Write("\tEnter a propriate number : "); userSelectStudent = Convert.ToInt32(Console.ReadLine()); if (userSelectStudent >= 0 && userSelectStudent <= allStudents.Count) { if (serviceCheck.ExistStudentsPerCourse((int)allStudents[userSelectStudent - 1].Sid, (int)allCourses[selectCourse - 1].Cid)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); Console.WriteLine("\tThe student already exist in the course."); Console.ForegroundColor = ConsoleColor.White; notSuccededAdd = true; } else { serviseInsert.InsertStudentAtCourse((int)allStudents[userSelectStudent - 1].Sid, (int)allCourses[selectCourse - 1].Cid); notSuccededAdd = false; } } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tPlease select a propriate number."); Console.ForegroundColor = ConsoleColor.White; notSuccededAdd = true; } } catch (Exception) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tPlease select a propriate number."); Console.ForegroundColor = ConsoleColor.White; notSuccededAdd = true; } } while (notSuccededAdd); //Ask to add another student from the list in course do { Console.WriteLine(); Console.Write("\tWould you like to add another student from the list in course? Y/N : "); addAnotherStudentfromList = Console.ReadLine(); Console.WriteLine(); } while (addAnotherStudentfromList.ToUpper() != "Y" && addAnotherStudentfromList.ToUpper() != "N"); } while (addAnotherStudentfromList.ToUpper() != "N"); } } while ((userInput5 != "1" && userInput5 != "2") && userInput5 != "9"); } //UserInput3 = 4, normal mode, Output students per course------------------------------------------------------------------------------------------------------- else if (userInput3 == "4") { sPC.ListOfStudentsPerCourseOutput(serviseGet.GetStudentsPerCourse()); MyStaticClass.PressKeyToContinue(); } //UserInput3 = 5, normal mode, Add trainers at courses------------------------------------------------------------------------------------------------------- else if (userInput3 == "5") { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); Console.WriteLine("\tSelect the number of course that you want to add trainers."); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; List <Course> allCourses = serviseGet.GetAllCourses(); c1.ListOfCoursecOutput(allCourses); Console.WriteLine(); do { Console.Write("\tEnter the apropriate number : "); selectCourse = MyStaticClass.InputTryToConvertToInt(); } while (selectCourse <= 0 || selectCourse > allCourses.Count); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n\t=================================================================================\n"); Console.ForegroundColor = ConsoleColor.White; do { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\tSelect how you want to add a trainer."); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(); Console.WriteLine("\t1. Add a new trainer."); Console.WriteLine("\t2. Add an excisting trainer."); Console.WriteLine("\t9. Go back."); Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : "); userInput5 = Console.ReadLine(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n\t=================================================================================\n"); Console.ForegroundColor = ConsoleColor.White; } while ((userInput5 != "1" && userInput5 != "2") && userInput5 != "9"); if (userInput5 == "1") { serviseInsert.InsertTrainer(); List <Trainer> trainers = serviseGet.GetAllTrainers(); serviseInsert.InsertTrainerAtCourse((int)trainers[trainers.Count - 1].Tid, (int)allCourses[selectCourse - 1].Cid); } else if (userInput5 == "2") { string addAnotherTrainerfromList; bool notSuccededAdd = true; do { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); Console.WriteLine("\tSelect the number of trainer."); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; List <Trainer> allTrainers = serviseGet.GetAllTrainers(); tr1.ListOfTrainersOutput(allTrainers); do { int selectTrainer = 0; try { Console.WriteLine(); Console.Write("\tEnter a propriate number : "); selectTrainer = Convert.ToInt32(Console.ReadLine()); if (selectTrainer >= 0 && selectTrainer <= allTrainers.Count) { if (serviceCheck.ExistTrainerPerCourse((int)allTrainers[selectTrainer - 1].Tid, (int)allCourses[selectCourse - 1].Cid)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); Console.WriteLine("\tThe trainer already exist in the course."); Console.ForegroundColor = ConsoleColor.White; notSuccededAdd = true; } else { serviseInsert.InsertTrainerAtCourse((int)allTrainers[selectTrainer - 1].Tid, (int)allCourses[selectCourse - 1].Cid); notSuccededAdd = false; } } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tPlease select a propriate number."); Console.ForegroundColor = ConsoleColor.White; notSuccededAdd = true; } } catch (Exception) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tPlease select a propriate number."); Console.ForegroundColor = ConsoleColor.White; notSuccededAdd = true; } } while (notSuccededAdd); //Ask to add another student from the list in course do { Console.WriteLine(); Console.Write("\tWould you like to add another student from the list in course? Y/N : "); addAnotherTrainerfromList = Console.ReadLine(); Console.WriteLine(); } while (addAnotherTrainerfromList.ToUpper() != "Y" && addAnotherTrainerfromList.ToUpper() != "N"); } while (addAnotherTrainerfromList.ToUpper() != "N"); } } //UserInput3 = 6, normal mode, Output trainers per course------------------------------------------------------------------------------------------------------- else if (userInput3 == "6") { tPC.ListOfTrainersPerCourseOutput(serviseGet.GetTrainersPerCourse()); MyStaticClass.PressKeyToContinue(); } //UserInput3 = 7, normal mode, Add assignments at courses------------------------------------------------------------------------------------------------------- else if (userInput3 == "7") { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); Console.WriteLine("\tSelect the number of course that you want to add assignments."); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; List <Course> allCourses = serviseGet.GetAllCourses(); c1.ListOfCoursecOutput(allCourses); Console.WriteLine(); do { Console.Write("\tEnter the apropriate number : "); selectCourse = MyStaticClass.InputTryToConvertToInt(); } while (selectCourse <= 0 || selectCourse > allCourses.Count); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n\t=================================================================================\n"); Console.ForegroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\tSelect how you want to add an assignment."); Console.ForegroundColor = ConsoleColor.White; do { Console.WriteLine(); Console.WriteLine("\t1. Add a new assignment."); Console.WriteLine("\t2. Add an excisting assignment."); Console.WriteLine("\t9. Go back."); Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : "); userInput5 = Console.ReadLine(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n\t=================================================================================\n"); Console.ForegroundColor = ConsoleColor.White; } while ((userInput5 != "1" && userInput5 != "2") && userInput5 != "9"); if (userInput5 == "1") { serviseInsert.InsertNewAssignmentAtCourse((int)allCourses[selectCourse - 1].Cid); } else if (userInput5 == "2") { string addAnotherAssignmentfromList; bool notSuccededAdd = true; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); Console.WriteLine("\tSelect the number of the assignment."); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; List <Assignment> allAssignments = serviseGet.GetAllAssignments(); a1.ListOfAssignmentsOutput(allAssignments); do { int selectAssignment = 0; try { Console.WriteLine(); Console.Write("\tEnter a propriate number : "); selectAssignment = Convert.ToInt32(Console.ReadLine()); if (selectAssignment >= 0 && selectAssignment <= allAssignments.Count) { serviseInsert.InsertAssignmentAtCourse((int)allAssignments[selectAssignment - 1].Aid, (int)allCourses[selectCourse - 1].Cid); notSuccededAdd = false; } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tPlease select a propriate number."); Console.ForegroundColor = ConsoleColor.White; notSuccededAdd = true; } } catch (Exception) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\tPlease select a propriate number."); Console.ForegroundColor = ConsoleColor.White; notSuccededAdd = true; } } while (notSuccededAdd); } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n\t=================================================================================\n"); Console.ForegroundColor = ConsoleColor.White; } //UserInput3 = 8, normal mode, Output assignments per course------------------------------------------------------------------------------------------------------- else if (userInput3 == "8") { aPC.OutputAssignmetsPerCourse(serviseGet.GetAssignmetsPerCourse()); MyStaticClass.PressKeyToContinue(); } } while (userInput3 != "0" && userInput3 != "9"); } //UserInput2 = 2, normal mode, Assignment-------------------------------------------------------------------------------------------------------------------- else if (userInput2 == "2") { do { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); Console.WriteLine("\tYou are in the assignment mode! What would you like to do?"); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\t0. Exit."); Console.WriteLine("\t1. New assignment."); Console.WriteLine("\t2. Output list with all assignments."); Console.WriteLine("\t3. Output list with assignments per course per student."); Console.WriteLine("\t9. Go back."); Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : "); userInput3 = Console.ReadLine(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n\t=================================================================================\n"); Console.ForegroundColor = ConsoleColor.White; //UserInput3 = 1, normal mode, New Assignment------------------------------------------------------------------------------------------------------- if (userInput3 == "1") { serviseInsert.InsertAssignment(); } //UserInput3 = 2, normal mode, List of assignments------------------------------------------------------------------------------------------------------- else if (userInput3 == "2") { a1.ListOfAssignmentsWithoutMarkOutput(serviseGet.GetAllAssignments()); MyStaticClass.PressKeyToContinue(); } else if (userInput3 == "3") { aPCPS.ListOfAssignmentsPerCoursePerStudentOutput(serviseGet.GetAssignmentsPerCoursePerStudents()); MyStaticClass.PressKeyToContinue(); } } while ((userInput3 != "0" && userInput3 != "9") && (userInput3 != "1" && (userInput3 != "2" && userInput3 != "3"))); } //UserInput2 = 3, normal mode, Trainer-------------------------------------------------------------------------------------------------------------------- else if (userInput2 == "3") { do { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); Console.WriteLine("\tYou are in the trainer mode! What would you like to do?"); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\t0. Exit."); Console.WriteLine("\t1. New trainer."); Console.WriteLine("\t2. Output list with all trainers."); Console.WriteLine("\t9. Go back."); Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : "); userInput3 = Console.ReadLine(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n\t=================================================================================\n"); Console.ForegroundColor = ConsoleColor.White; //UserInput3 = 1, normal mode, New trainer------------------------------------------------------------------------------------------------------- if (userInput3 == "1") { serviseInsert.InsertTrainer(); } //UserInput3 = 2, normal mode, List of trainers------------------------------------------------------------------------------------------------------- else if (userInput3 == "2") { tr1.ListOfTrainersOutput(serviseGet.GetAllTrainers()); MyStaticClass.PressKeyToContinue(); } } while ((userInput3 != "0" && userInput3 != "9") && (userInput3 != "1" && userInput3 != "2")); } //UserInput2 = 4, normal mode, Student-------------------------------------------------------------------------------------------------------------------- else if (userInput2 == "4") { do { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); Console.WriteLine("\tYou are in the student mode! What would you like to do?"); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\t0. Exit."); Console.WriteLine("\t1. New student."); Console.WriteLine("\t2. Output list with all students."); Console.WriteLine("\t3. Output list witn students who belongs to more than one course."); Console.WriteLine("\t9. Go back."); Console.Write("\n\tPlease enter the appropriate number to select the field you are interested in : "); userInput3 = Console.ReadLine(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\n\t=================================================================================\n"); Console.ForegroundColor = ConsoleColor.White; //UserInput3 = 1, normal mode, New Student------------------------------------------------------------------------------------------------------- if (userInput3 == "1") { serviseInsert.InsertStudent(); } //UserInput3 = 2, normal mode, List of students------------------------------------------------------------------------------------------------------- else if (userInput3 == "2") { s1.ListOfStudentsOutput(serviseGet.GetAllStudents()); MyStaticClass.PressKeyToContinue(); } //UserInput3 = 3, normal mode, List of students who belongs to more than one course------------------------------------------------------------------------------------------------------ - else if (userInput3 == "3") { sMTOC.ListOfStudentsOutput(serviseGet.GetStudentsWithMoreThanOneCourses()); MyStaticClass.PressKeyToContinue(); } } while ((userInput3 != "0" && userInput3 != "9") && (userInput3 != "1" && userInput3 != "2") && (userInput3 != "3")); } } while ((userInput2 != "0" && userInput2 != "9") && userInput3 != "0"); Console.WriteLine("\n\tTHANK YOU!!!"); Console.ReadKey(); }
public Data() { //creating students Student s1 = new Student("Panagiotis", "Grigoriou", new DateTime(1987, 3, 4), 3000); Student s2 = new Student("Konstantinos", "Pantelidis", new DateTime(1991, 6, 2), 4000); Student s3 = new Student("Spiros", "Aggelatos", new DateTime(1996, 4, 7), 3500); Student s4 = new Student("Dimitris", "Pantelopoulos", new DateTime(2000, 5, 2), 6200); Student s5 = new Student("Antonis", "Mixelakakis", new DateTime(1989, 10, 3), 5800); Students.Add(s1); Students.Add(s2); Students.Add(s3); Students.Add(s4); Students.Add(s5); //creating courses Course c1 = new Course("Javascript", "Web Development", "Practical Subject", new DateTime(2020, 1, 10), new DateTime(2020, 3, 11)); Course c2 = new Course("C++", "Object-Oriented Programming", "Practical Subject", new DateTime(2020, 1, 18), new DateTime(2020, 4, 2)); Course c3 = new Course("Pascal", "Procedural Programming", "Theoretical Subject", new DateTime(2020, 2, 15), new DateTime(2020, 5, 20)); Course c4 = new Course("Visual Basic", "Windows Application Development", "Practical Subject", new DateTime(2020, 3, 20), new DateTime(2020, 6, 1)); Courses.Add(c1); Courses.Add(c2); Courses.Add(c3); Courses.Add(c4); //creating trainers Trainer t1 = new Trainer("Giannis", "Aggelopoulos", "Object-Oriented Programming"); Trainer t2 = new Trainer("Manolis", "Daskalakis", "Procedural Programming"); Trainer t3 = new Trainer("Giorgos", "Mpatzoglou", "Procedural Programming"); Trainer t4 = new Trainer("Thanassis", "Giorgakopoulos", "Object-Oriented Programming"); Trainers.Add(t1); Trainers.Add(t2); Trainers.Add(t3); Trainers.Add(t4); //creating assignments Assignment a1 = new Assignment("Project Bank", "Banking application for android phones", new DateTime(2020, 4, 24), 40, 200); Assignment a2 = new Assignment("Project E-shop", "Shopping website", new DateTime(2020, 6, 11), 20, 100); Assignment a3 = new Assignment("Project Library", "Book rental service", new DateTime(2020, 4, 15), 35, 200); Assignment a4 = new Assignment("Project Cinema", "Movie distribution to cinemas", new DateTime(2020, 1, 2), 73, 100); Assignment a5 = new Assignment("Project Stocks", "Stock change notifications", new DateTime(2020, 3, 27), 110, 200); Assignment a6 = new Assignment("Project Architecture", "Blueprint making software", new DateTime(2020, 3, 24), 40, 150); Assignments.Add(a1); Assignments.Add(a2); Assignments.Add(a3); Assignments.Add(a4); Assignments.Add(a5); Assignments.Add(a6); //putting students in mini-lists (students per Course) List <Student> C1Stu = new List <Student>(); List <Student> C2Stu = new List <Student>(); List <Student> C3Stu = new List <Student>(); C1Stu.Add(s2); C1Stu.Add(s3); C2Stu.Add(s1); C2Stu.Add(s2); C2Stu.Add(s3); C3Stu.Add(s1); //putting mini-lists in big lists (students per Course) StudentPerCourse stuPerCour1 = new StudentPerCourse(c1, C1Stu); StudentPerCourse stuPerCour2 = new StudentPerCourse(c2, C2Stu); StudentPerCourse stuPerCour3 = new StudentPerCourse(c3, C3Stu); StudentsPerCourse.Add(stuPerCour1); StudentsPerCourse.Add(stuPerCour2); StudentsPerCourse.Add(stuPerCour3); //putting trainers in mini-lists (trainers per Course) List <Trainer> C1Train = new List <Trainer>(); List <Trainer> C2Train = new List <Trainer>(); List <Trainer> C3Train = new List <Trainer>(); C1Train.Add(t1); C1Train.Add(t2); C2Train.Add(t1); C2Train.Add(t3); C3Train.Add(t4); C3Train.Add(t1); //putting mini-lists in big lists (trainers per Course) TrainerPerCourse trainPerCour1 = new TrainerPerCourse(c1, C1Train); TrainerPerCourse trainPerCour2 = new TrainerPerCourse(c2, C2Train); TrainerPerCourse trainPerCour3 = new TrainerPerCourse(c3, C3Train); TrainersPerCourse.Add(trainPerCour1); TrainersPerCourse.Add(trainPerCour2); TrainersPerCourse.Add(trainPerCour3); //putting assignments in mini-lists (assignments per Course) List <Assignment> C1Assign = new List <Assignment>(); List <Assignment> C2Assign = new List <Assignment>(); List <Assignment> C3Assign = new List <Assignment>(); C1Assign.Add(a1); C1Assign.Add(a2); C2Assign.Add(a3); C3Assign.Add(a5); C3Assign.Add(a4); //putting mini-lists in big lists (assignments per Course) AssignmentPerCourse assignPerCour1 = new AssignmentPerCourse(c1, C1Assign); AssignmentPerCourse assignPerCour2 = new AssignmentPerCourse(c2, C2Assign); AssignmentPerCourse assignPerCour3 = new AssignmentPerCourse(c3, C2Assign); AssignmentsPerCourse.Add(assignPerCour1); AssignmentsPerCourse.Add(assignPerCour2); AssignmentsPerCourse.Add(assignPerCour3); //putting assignments in mini-lists (assignments per Student) List <Assignment> S1Assign = new List <Assignment>(); List <Assignment> S2Assign = new List <Assignment>(); List <Assignment> S3Assign = new List <Assignment>(); S1Assign.Add(a1); S1Assign.Add(a2); S2Assign.Add(a3); S2Assign.Add(a4); S2Assign.Add(a5); S3Assign.Add(a6); //putting mini-lists in big lists (assignments per Student) AssignmentPerStudent assignPerStu1 = new AssignmentPerStudent(s1, S1Assign); AssignmentPerStudent assignPerStu2 = new AssignmentPerStudent(s2, S2Assign); AssignmentPerStudent assignPerStu3 = new AssignmentPerStudent(s3, S3Assign); AssignmentsPerStudent.Add(assignPerStu1); AssignmentsPerStudent.Add(assignPerStu2); AssignmentsPerStudent.Add(assignPerStu3); //putting courses in mini-lists (courses per Student) List <Course> S1Cour = new List <Course>(); List <Course> S2Cour = new List <Course>(); List <Course> S3Cour = new List <Course>(); S1Cour.Add(c2); S1Cour.Add(c3); S2Cour.Add(c1); S2Cour.Add(c2); S3Cour.Add(c1); S3Cour.Add(c2); //putting mini-lists in big lists (courses per Student) CoursePerStudent courPerStu1 = new CoursePerStudent(s1, S1Cour); CoursePerStudent courPerStu2 = new CoursePerStudent(s2, S2Cour); CoursePerStudent courPerStu3 = new CoursePerStudent(s3, S3Cour); CoursesPerStudent.Add(courPerStu1); CoursesPerStudent.Add(courPerStu2); CoursesPerStudent.Add(courPerStu3); //------------------------------------------------------- //AssignmentCourseStudent ACS1 = new AssignmentCourseStudent(s1, c2, a3); //AssignmentCourseStudent ACS2 = new AssignmentCourseStudent(s1, c3, a6); //AssignmentCourseStudent ACS3 = new AssignmentCourseStudent(s2, c1, a1); //AssignmentCourseStudent ACS4 = new AssignmentCourseStudent(s2, c2, a4); //AssignmentCourseStudent ACS5 = new AssignmentCourseStudent(s3, c1, a2); //AssignmentCourseStudent ACS6 = new AssignmentCourseStudent(s3, c2, a5); //ACSList.Add(ACS1); //ACSList.Add(ACS2); //ACSList.Add(ACS3); //ACSList.Add(ACS4); //ACSList.Add(ACS5); //ACSList.Add(ACS6); }
public Menu(CoursesList courses, AssignmentsList assignments, StudentsList students, TrainersList trainers) { Console.WriteLine(" Welcome to our school!"); while (!exit) { Console.Write(options); string option = Console.ReadLine(); switch (option) { case "1": if (!sampleDataImported) { Synthetic sample = new Synthetic(); sample.Create(); students.List.AddRange(sample.Students.List); trainers.List.AddRange(sample.Trainers.List); assignments.List.AddRange(sample.Assignments.List); courses.List.AddRange(sample.Courses.List); Console.WriteLine("\n Sample Data imported."); sampleDataImported = true; } else { Console.WriteLine("\n You have already imported sample data."); } break; case "2": students.AddNew(); courses.AddToCourse(students.List[students.List.Count - 1], null, null); break; case "3": trainers.AddNew(); courses.AddToCourse(null, trainers.List[trainers.List.Count - 1], null); break; case "4": courses.AddNew(); break; case "5": assignments.AddNew(); courses.AddToCourse(null, null, assignments.List[assignments.List.Count - 1]); break; case "6": Console.WriteLine(students.ToString()); break; case "7": Console.WriteLine(trainers.ToString()); break; case "8": Console.WriteLine(courses.ToString()); break; case "9": Console.WriteLine(assignments.ToString()); break; case "10": Console.Write(" Give course title:"); string courseTitle = Console.ReadLine(); StudentsPerCourse studentsPerCourse = new StudentsPerCourse(courses, courseTitle); Console.WriteLine(studentsPerCourse.ToString()); break; case "11": Console.Write(" Give course title:"); courseTitle = Console.ReadLine(); TrainersPerCourse trainersPerCourse = new TrainersPerCourse(courses, courseTitle); Console.WriteLine(trainersPerCourse.ToString()); break; case "12": Console.Write(" Give course title:"); courseTitle = Console.ReadLine(); AssignmentsPerCourse assignmentsPerCourse = new AssignmentsPerCourse(courses, courseTitle); Console.WriteLine(assignmentsPerCourse.ToString()); break; case "13": Console.Write(" Give student's first name:"); string firstname = Console.ReadLine(); Console.Write(" Give student's last name:"); string lastname = Console.ReadLine(); AssignmentsPerStudent assignmentsPerStudent = new AssignmentsPerStudent(courses, firstname, lastname); Console.WriteLine(assignmentsPerStudent.ToString()); break; case "14": StudentsInMoreCourses studentsInMoreCourses = new StudentsInMoreCourses(courses); Console.WriteLine(studentsInMoreCourses.ToString()); break; case "15": Console.Write(" Give a date (y/m/d):"); DateTime date; while (!DateTime.TryParse(Console.ReadLine(), out date)) { Console.Write("Wrong Input. Enter a valid date (y/m/d):"); } StudentsWithSubmission studentsWithSubmission = new StudentsWithSubmission(courses, date); Console.WriteLine(" Students submitting assignments" + $"\n from {studentsWithSubmission.StartDate:D} to {studentsWithSubmission.StartDate.AddDays(4):D}:"); Console.WriteLine(studentsWithSubmission.ToString()); break; case "16": exit = true; break; default: Console.WriteLine("Wrong input."); break; } } }