public ICollection <Student> GetStudents(Tutor tutor) { ICollection <Student> students = new HashSet <Student>(); if (Assignments != null) { foreach (Assignment assignment in Assignments) { foreach (Student student in assignment.GetStudents(tutor)) { students.Add(student); } } } return(students); }
public CourseDetailDTO(Course course, Student student, Tutor tutor, Teacher teacher, ICollection <GradingScheme> schemes) : base(course) { if (course != null) { GradingSchemes = new HashSet <GradingSchemeListDTO>(); Assignments = new HashSet <AssignmentListDTO>(); MinRequiredAssignments = course.MinRequiredAssignments; MinRequiredScore = course.MinRequiredScore; if (course.GradingScheme != null) { GradingScheme = new GradingSchemeDetailDTO(course.GradingScheme); } if (course.Teacher != null) { Teacher = new UserListDTO(course.Teacher.User); } foreach (Assignment assignment in course.Assignments) { Assignments.Add(new AssignmentListDTO(assignment)); } Final = course.IsFinal(); if (course.IsFinal()) { if (student != null && course.GetStudents(null).Contains(student)) { Result = new CourseResult(student, course, false); } else { Results = new HashSet <CourseResult>(); foreach (Student otherStudent in course.GetStudents(teacher != null ? null : tutor)) { Results.Add(new CourseResult(otherStudent, course, true)); } } } if (schemes != null) { foreach (GradingScheme scheme in schemes) { GradingSchemes.Add(new GradingSchemeListDTO(scheme)); } } } }
protected AssignmentDetailDTO(Assignment assignment, Tutor tutor) : base(assignment) { if (assignment != null) { Lessons = new HashSet <LessonListDTO>(); if (assignment.Course != null) { Course = new CourseListDTO(assignment.Course); } if (assignment.Lessons != null) { foreach (Lesson lesson in assignment.Lessons) { Lessons.Add(new LessonListDTO(lesson, tutor)); } } } }
public LessonListDTO(Lesson lesson, Tutor tutor) { if (lesson != null) { Id = lesson.Id; Number = lesson.Number; Date = lesson.Date; IsOwnLesson = true; if (lesson.Tutor != null) { Tutor = new UserListDTO(lesson.Tutor.User); if (tutor != null) { IsOwnLesson = lesson.Tutor.Equals(tutor); } } } }
public ICollection <Student> GetStudents(Tutor tutor) { ICollection <Student> students = new HashSet <Student>(); if (Lessons != null) { foreach (Lesson lesson in Lessons) { if (tutor != null && !tutor.Equals(lesson.Tutor)) { continue; } foreach (Student student in lesson.GetStudents()) { students.Add(student); } } } return(students); }
public AssignmentDetailTeacherDTO(Assignment assignment, Student student, Tutor tutor, Teacher teacher) : base(assignment, student, tutor) { Results = new HashSet <AssignmentResult>(); if (assignment != null) { if (Tasks.Count == 0) { foreach (Task task in assignment.Tasks) { Tasks.Add(new TaskListDTO(task)); } } if (teacher != null || tutor != null) { ICollection <Student> students = assignment.GetStudents(teacher != null ? null : tutor); foreach (Student otherStudent in students) { Results.Add(new AssignmentResult(otherStudent, assignment, true)); } } } }