Пример #1
0
        public async Task <CourseDetailsModel> GetCourseDetails(int courseId)
        {
            try
            {
                var result        = new CourseDetailsModel();
                var courseDetails = await _coursesRepository.GetCourseDetails(courseId);

                if (courseDetails != null)
                {
                    result.CourseDetails = _mapper.Map <CourseModel>(courseDetails);
                    if (courseDetails.StudentCourses != null && courseDetails.StudentCourses.Count > 0)
                    {
                        foreach (var item in courseDetails.StudentCourses)
                        {
                            var student = _mapper.Map <StudentDetails>(item.Student);
                            result.CourseStudents.Add(student);
                        }
                    }
                }
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }