static void addNewLoop(availableTypes typeToAdd, Course course) { do { switch (typeToAdd) { case availableTypes.Trainer: Trainer newTrainer = createTrainer(); course.addToCourse(newTrainer); break; case availableTypes.Student: Student newStudent = createStudent(); course.addToCourse(newStudent); break; case availableTypes.Assignment: Assignment newAssignment = createAssignment(course); course.addToCourse(newAssignment); break; default: Console.WriteLine("You cannot add {0} to the DataBase.", typeToAdd); break; } Console.WriteLine("\nWould you like to add another {0} to this Course? (y/n)", typeToAdd); } while (Helper.yesInput()); }
public void showConnections(availableTypes typeToShow, bool showContainerInfo) { if (showContainerInfo) { DataBase.show(this, "\nStudent: "); } connections.showConnections(typeToShow); }
public static void showCourseInfo(availableTypes typeToShow) { do { Console.WriteLine("\nPlease choose the Course you want to see its {0}s.\n", typeToShow); Course course = chooseCourse(); course.showConnections(typeToShow); Console.WriteLine("\nWould you like to see the {0}s of another Course? (y/n)", typeToShow); } while (Helper.yesInput()); }
public static void addNew(availableTypes typeToAdd) { if (typeToAdd == availableTypes.Course) { do { Course newcourse = createCourse(); Console.WriteLine(); Console.WriteLine("\nWould you like to add another course? (y/n)"); } while (Helper.yesInput()); } else { Console.WriteLine("Every {0} must belong to at least one Course.\nPlease choose the Course you want to add the {1}", typeToAdd, typeToAdd); Course course = chooseCourse(); addNewLoop(typeToAdd, course); } }
public static void showStudentInfo(availableTypes typeToShow) { if (Helper.checkListEmpty(DataBase.getAllStudents())) { Console.WriteLine("You don't have any students yet.\nWould you like to add a new student? (y/n)"); if (Helper.yesInput()) { addNew(availableTypes.Student); } } else { do { Console.WriteLine("\nPlease choose the student you want to see his {0}.", typeToShow); Student student = chooseStudent(); student.showConnections(typeToShow, true); Console.WriteLine("\nWould you like to see the {0}s of another Student? (y/n)", typeToShow); } while (Helper.yesInput()); } }
public static void showStudentInfo(availableTypes typeToShow) { IndividualPartBModel db = new IndividualPartBModel(); if (!(db.Students.Count() > 0)) { Console.WriteLine("You don't have any students yet.\nWould you like to add a new student? (y/n)"); if (Helper.yesInput()) { addNew(availableTypes.Student); } } else { do { Console.WriteLine("\nPlease choose the student you want to see his {0}.", typeToShow); Students student = chooseStudent(); student.showConnections(typeToShow, true); Console.WriteLine("\nWould you like to see the {0}s of another Student? (y/n)", typeToShow); } while (Helper.yesInput()); } }
public IList <int> getList(availableTypes typeToGet) { IList <int> readOnlyList = null; switch (typeToGet) { case availableTypes.Course: readOnlyList = listOfCoursesIDs; break; case availableTypes.Trainer: readOnlyList = listOfTrainersIDs; break; case availableTypes.Student: readOnlyList = listOfStudentsIDs; break; case availableTypes.Assignment: readOnlyList = listOfAssignmentsIDs; break; } return(readOnlyList); }
public virtual void showConnections(availableTypes typeToShow) { int counter = 1; switch (typeToShow) { case availableTypes.Course: if (listOfCoursesIDs != null) { Console.WriteLine("\nCourses:"); if (Helper.checkListEmpty(listOfCoursesIDs)) { Console.WriteLine("\nThe {0} has no Courses yet.", typeOfConnections); } else { foreach (int ID in listOfCoursesIDs) { int positionInDb = ID - 1; Course course = DataBase.getAllCourses()[positionInDb]; DataBase.show(course, (" " + counter + ". ").ToString()); counter++; } } } break; case availableTypes.Trainer: if (listOfTrainersIDs != null) { Console.WriteLine("\nTrainers:"); if (Helper.checkListEmpty(listOfTrainersIDs)) { Console.WriteLine("\nThe {0} has no Trainers yet.", typeOfConnections); } else { foreach (int ID in listOfTrainersIDs) { int positionInDb = ID - 1; Trainer trainer = DataBase.getAllTrainers()[positionInDb]; DataBase.show(trainer, (" " + counter + ". ").ToString()); counter++; } } } break; case availableTypes.Student: if (listOfStudentsIDs != null) { Console.WriteLine("\nStudents:"); if (Helper.checkListEmpty(listOfStudentsIDs)) { Console.WriteLine("\nThe {0} has no Students yet.", typeOfConnections); } else { foreach (int ID in listOfStudentsIDs) { int positionInDb = ID - 1; Student student = DataBase.getAllStudents()[positionInDb]; DataBase.show(student, (" " + counter + ". ").ToString()); counter++; } } } break; case availableTypes.Assignment: if (listOfAssignmentsIDs != null) { Console.WriteLine("\nAssignments:"); if (Helper.checkListEmpty(listOfAssignmentsIDs)) { Console.WriteLine("\nThe {0} has no Assignments yet.", typeOfConnections); } else { foreach (int ID in listOfAssignmentsIDs) { int positionInDb = ID - 1; Assignment assignment = DataBase.getAllAssignments()[positionInDb]; DataBase.show(assignment, (" " + counter + ". ").ToString()); counter++; } } } break; default: Console.WriteLine("The {0} doesn't support connections.", typeToShow); break; } }
public static void addToCourse(availableTypes typeToAdd) { Console.WriteLine("\nPlease choose the course you want to add the {0}.\n", typeToAdd); Course course = chooseCourse(); bool emptyListFlag = true; switch (typeToAdd) { case availableTypes.Trainer: emptyListFlag = Helper.checkListEmpty(DataBase.getAllTrainers()); break; case availableTypes.Student: emptyListFlag = Helper.checkListEmpty(DataBase.getAllStudents()); break; case availableTypes.Assignment: emptyListFlag = Helper.checkListEmpty(DataBase.getAllAssignments()); break; } if (emptyListFlag) { Console.WriteLine("You don't have any {0} yet.\nWould you like to add a new {1}? (y/n)", typeToAdd, typeToAdd); if (Helper.yesInput()) { addNewLoop(typeToAdd, course); } } else { Console.WriteLine("\nPlease choose the {0} you want to add the Course.\n", typeToAdd); do { switch (typeToAdd) { case availableTypes.Trainer: Trainer trainer = chooseTrainer(); course.addToCourse(trainer); break; case availableTypes.Student: Student student = chooseStudent(); course.addToCourse(student); break; case availableTypes.Assignment: Assignment assignment = chooseAssignment(); if (assignment.SubDateTime < course.StartDate || assignment.SubDateTime > course.EndDate) { Console.WriteLine("The submit date of the assignment is out of range of the dates of the course.\nAre you sure you want to add the assignment? (y/n)"); if (Helper.yesInput()) { course.addToCourse(assignment); } } else { course.addToCourse(assignment); } break; } Console.WriteLine("\nWould you like to add another {0} to the course? (y/n)", typeToAdd); } while (Helper.yesInput()); } }
public static void showAllConnections(availableTypes typeToShow) { bool emptyListFlag = true; switch (typeToShow) { case availableTypes.Course: emptyListFlag = Helper.checkListEmpty(DataBase.getAllCourses()); break; case availableTypes.Trainer: emptyListFlag = Helper.checkListEmpty(DataBase.getAllTrainers()); break; case availableTypes.Student: emptyListFlag = Helper.checkListEmpty(DataBase.getAllStudents()); break; case availableTypes.Assignment: emptyListFlag = Helper.checkListEmpty(DataBase.getAllAssignments()); break; } if (emptyListFlag) { Console.WriteLine("\nThere are no {0}s yet.", typeToShow); } switch (typeToShow) { case availableTypes.Course: foreach (Course course in DataBase.getAllCourses()) { course.connectionsAnalysis(); Console.WriteLine(". . . . . . . . . . . . . . . . . . . ."); } break; case availableTypes.Trainer: foreach (Trainer trainer in DataBase.getAllTrainers()) { trainer.connectionsAnalysis(); Console.WriteLine(". . . . . . . . . . . . . . . . . . . ."); } break; case availableTypes.Student: foreach (Student student in DataBase.getAllStudents()) { student.connectionsAnalysis(); Console.WriteLine(". . . . . . . . . . . . . . . . . . . ."); } break; case availableTypes.Assignment: foreach (Assignment assignment in DataBase.getAllAssignments()) { assignment.connectionsAnalysis(); Console.WriteLine(". . . . . . . . . . . . . . . . . . . ."); } break; default: Console.WriteLine("The DataBase doesn't support {0} connections.", typeToShow); break; } }
public static void addToCourse(availableTypes typeToAdd) { IndividualPartBModel db = new IndividualPartBModel(); Console.WriteLine("\nPlease choose the course you want to add the {0}.\n", typeToAdd); Courses course = chooseCourse(); bool emptyListFlag = true; switch (typeToAdd) { case availableTypes.Trainer: emptyListFlag = db.Trainers.Count() > 0 ? false : true; break; case availableTypes.Student: emptyListFlag = db.Students.Count() > 0 ? false : true; break; case availableTypes.Assignment: emptyListFlag = db.Assignments.Count() > 0 ? false : true; break; } if (emptyListFlag) { Console.WriteLine("You don't have any {0} yet.\nWould you like to add a new {1}? (y/n)", typeToAdd, typeToAdd); if (Helper.yesInput()) { addNewLoop(typeToAdd, course); } } else { Console.WriteLine("\nPlease choose the {0} you want to add the Course.\n", typeToAdd); do { switch (typeToAdd) { case availableTypes.Trainer: Trainers trainer = chooseTrainer(); course.addToCourse(trainer); break; case availableTypes.Student: Students student = chooseStudent(); course.addToCourse(student); break; case availableTypes.Assignment: Assignments assignment = chooseAssignment(); if (assignment.subDateTime < course.start_date || assignment.subDateTime > course.end_date) { Console.WriteLine("The submit date of the assignment is out of range of the dates of the course.\nAre you sure you want to add the assignment? (y/n)"); if (Helper.yesInput()) { course.addToCourse(assignment); } } else { course.addToCourse(assignment); } break; } Console.WriteLine("\nWould you like to add another {0} to the course? (y/n)", typeToAdd); } while (Helper.yesInput()); } }
public static void showAllConnections(availableTypes typeToShow) { IndividualPartBModel db = new IndividualPartBModel(); bool emptyListFlag = true; switch (typeToShow) { case availableTypes.Course: emptyListFlag = db.Courses.Count() > 0 ? false : true; break; case availableTypes.Trainer: emptyListFlag = db.Trainers.Count() > 0 ? false : true; break; case availableTypes.Student: emptyListFlag = db.Students.Count() > 0 ? false : true; break; case availableTypes.Assignment: emptyListFlag = db.Assignments.Count() > 0 ? false : true; break; } if (emptyListFlag) { Console.WriteLine("\nThere are no {0}s yet.", typeToShow); } switch (typeToShow) { case availableTypes.Course: foreach (Courses course in db.Courses.ToList()) { course.connectionsAnalysis(); Console.WriteLine(". . . . . . . . . . . . . . . . . . . ."); } break; case availableTypes.Trainer: foreach (Trainers trainer in db.Trainers.ToList()) { trainer.connectionsAnalysis(); Console.WriteLine(". . . . . . . . . . . . . . . . . . . ."); } break; case availableTypes.Student: foreach (Students student in db.Students.ToList()) { student.connectionsAnalysis(); Console.WriteLine(". . . . . . . . . . . . . . . . . . . ."); } break; case availableTypes.Assignment: foreach (Assignments assignment in db.Assignments.ToList()) { assignment.connectionsAnalysis(); Console.WriteLine(". . . . . . . . . . . . . . . . . . . ."); } break; default: Console.WriteLine("The DataBase doesn't support {0} connections.", typeToShow); break; } }
public override void showConnections(availableTypes typeToShow) { DataBase.show(this, "\nCourse: "); base.showConnections(typeToShow); }