Example #1
0
        public List <CourseOverview> GetCourseOverview()
        {
            var courseEntries = _courseService.GetCourses();
            List <CourseOverview> overviews = new List <CourseOverview>();

            foreach (var course in courseEntries)
            {
                overviews.Add(new CourseOverview
                {
                    Course        = _mapper.Map <Course, CourseDTO>(course),
                    TeachersCount = _teacherService.GetTeachersBy(course.Id).Count(),
                    StudentsCount = _studentService.SearchStudentsBy(course.Id).Count(),
                    AverageGrade  = String.Format("{0:0.0#}", _gradeService.GetAverageByCourse(course.Id))
                });
            }

            return(overviews);
        }