Exemplo n.º 1
0
        public List <CourseTeachersStudentsAverageGradesModelView> CreateCourseTeachersStudentsAverageGradesModelView(List <Course> courses)
        {
            teacherService        = new TeacherService();
            studentSubjectService = new StudentSubjectService();
            studentService        = new StudentService();

            int   numberOfTeacherFromACourse;
            int   numberOfEnrolledAndRegisteredStudentsInACourse;
            Grade?averageGrade;

            List <CourseTeachersStudentsAverageGradesModelView> viewModel = new List <CourseTeachersStudentsAverageGradesModelView>();

            foreach (Course course in courses)
            {
                numberOfTeacherFromACourse = teacherService.GetNumberOfTeachersPerCourse(course);

                numberOfEnrolledAndRegisteredStudentsInACourse = studentService
                                                                 .GetStudentsRegisteredInACourse(course).Count();

                averageGrade = studentSubjectService.GetStudentAverageGradePerCourse(course);

                CourseTeachersStudentsAverageGradesModelView CourseTeachersStudentsAverageGradesModelView
                    = new CourseTeachersStudentsAverageGradesModelView()
                    {
                    Course           = course,
                    numberOfTeachers = numberOfTeacherFromACourse,
                    numberOfStudents = numberOfEnrolledAndRegisteredStudentsInACourse,
                    averageGrade     = averageGrade
                    };

                viewModel.Add(CourseTeachersStudentsAverageGradesModelView);
            }

            return(viewModel);
        }
Exemplo n.º 2
0
        public List <TeacherSubjectNumberOfStudentsViewModel> CreateTeacherSubjectNumberOfStudentsViewModel(Teacher teacher, IEnumerable <Subject> teacherSubjects)
        {
            int numberOfStudents = 0;

            List <TeacherSubjectNumberOfStudentsViewModel> viewModel =
                new List <TeacherSubjectNumberOfStudentsViewModel>();

            foreach (Subject subject in teacherSubjects)
            {
                studentSubjectService = new StudentSubjectService();

                numberOfStudents = studentSubjectService.NumberOfStudentsPerSubject(subject);

                TeacherSubjectNumberOfStudentsViewModel model =
                    new TeacherSubjectNumberOfStudentsViewModel()
                {
                    Teacher          = teacher,
                    Subject          = subject,
                    NumberOfStudents = numberOfStudents
                };

                viewModel.Add(model);
            }

            return(viewModel);
        }
Exemplo n.º 3
0
        public IEnumerable <StudentSubject> GetTeacherStudentSubjectsByTeacherId(int teacherId)
        {
            studentSubjectService = new StudentSubjectService();

            IEnumerable <StudentSubject> teachersStudentSubjects = studentSubjectService.
                                                                   GetStudentSubjectsByTeacherId(teacherId);

            return(teachersStudentSubjects);
        }
Exemplo n.º 4
0
        public Grade?GetStudentAverageGradePerCourse(Course course)
        {
            studentService        = new StudentService();
            subjectService        = new SubjectService();
            studentSubjectService = new StudentSubjectService();
            gradeService          = new GradeService();

            int   studentsAverageGrade;
            int   studentsAverageRounded;
            Grade?averageGrade;

            List <Subject> subjectsFromACourse = subjectService.GetSubjectsFromACourse(course);

            int numberOfSubjectsInACourse = subjectsFromACourse.Count();

            int numberOfStudentsRegisteredInACourse = studentService
                                                      .GetStudentsRegisteredInACourse(course).Count();

            int studentsTotalGrades = studentSubjectService
                                      .GetTotalStudentGradesFromACourse(course);

            int numberOfStudentSubjectsGraded = GetNumberOfStudentsSubjectsGradedInACourse(subjectsFromACourse);


            if (numberOfSubjectsInACourse != 0 && numberOfStudentSubjectsGraded != 0)
            {
                studentsAverageGrade =
                    studentsTotalGrades / numberOfStudentSubjectsGraded;
            }
            else
            {
                studentsAverageGrade = 0;
            }

            studentsAverageRounded = (int)Math.Round((decimal)studentsAverageGrade);

            averageGrade = gradeService.ConvertIntToGrade(studentsAverageRounded);


            return(averageGrade);
        }
Exemplo n.º 5
0
        public Student RegisterStudent(UniversityStudentsList student)
        {
            courseSubjectService          = new CourseSubjectService();
            studentService                = new StudentService();
            studentSubjectService         = new StudentSubjectService();
            universityStudentsListService = new UniversityStudentsListService();


            Student studentToRegister = new Student();

            // adding and saving student to db, changing university list isEnrolled to true
            studentToRegister = studentService.AddStudent(student);

            //populate student with student subjects
            ICollection <Subject> studentCourseSubjects = new List <Subject>();

            studentCourseSubjects = courseSubjectService.GetSubjectsFromCourse(studentToRegister.CourseId);

            studentSubjectService.CreateStudentSubjectList(studentCourseSubjects.ToList(),
                                                           studentToRegister);

            return(studentToRegister);
        }