Exemple #1
0
        public IEnumerable <CourseSubject> CreateCourseSubjectToChooseByCourseIdAndSubjectToDelete
            (int courseId, int id, List <Subject> subjects)
        {
            subjectService = new SubjectService();
            courseService  = new CourseService();

            Subject subjectToRemove = subjectService.getSubjectById(id);
            Course  course          = courseService.GetCourseByCourseId(courseId);

            if (subjectToRemove == null)
            {
                return(null);
            }

            subjects.Remove(subjectToRemove);

            List <CourseSubject> subjectsToChoose = new List <CourseSubject>();

            foreach (Subject subject in subjects)
            {
                CourseSubject courseSubject = new CourseSubject()
                {
                    Course  = course,
                    Subject = subject
                };

                subjectsToChoose.Add(courseSubject);
            }

            return(subjectsToChoose);
        }
Exemple #2
0
        public Dictionary <Subject, Teacher> getSubjectTeacherPairs(int courseId)
        {
            Dictionary <Subject, Teacher> subjectTeacherPairs =
                new  Dictionary <Subject, Teacher>();

            IEnumerable <CourseSubject> allCourseSubjects = db.CourseSubjects.ToList();

            teacherService = new TeacherService();
            subjectService = new SubjectService();

            foreach (CourseSubject courseSubject in allCourseSubjects)
            {
                if (courseSubject.CourseId == courseId)
                {
                    Subject wantedSubject = subjectService
                                            .getSubjectById(courseSubject.SubjectId);

                    Teacher wantedTeacher = teacherService
                                            .getCorrespondingTeacher(wantedSubject.TeacherId);

                    subjectTeacherPairs.Add(wantedSubject, wantedTeacher);
                }
            }

            return(subjectTeacherPairs);
        }
Exemple #3
0
        public List <Subject> GetSubjectsFromCourse(int courseId)
        {
            List <Subject> studentSubjects             = new List <Subject>();
            IEnumerable <CourseSubject> courseSubjects = db.CourseSubjects.ToList();
            Subject subject = new Subject();
            int     subjectId;

            subjectService = new SubjectService();

            foreach (CourseSubject courseSubject in courseSubjects)
            {
                if (courseSubject.CourseId == courseId)
                {
                    subjectId = courseSubject.SubjectId;

                    subject = subjectService.getSubjectById(subjectId);

                    studentSubjects.Add(subject);
                }
            }

            return((List <Subject>)studentSubjects);
        }