public IActionResult Course() { var course = _context.Course .FirstOrDefault(); var modules = _moduleRepository.GetModulesForCourse(course.Id);; var viewModel = new CourseViewModel { Name = course.Name, ModulesVM = modules.Select(r => new ModuleViewModel { Id = r.Id, Name = r.Name, Facts = r.Facts.Select(f => new FactViewModel { Id = f.Id, Name = f.Name }), Exams = r.ExamFile.Select(e => new ExamViewModel { Id = e.Id, Name = e.Name }), Exercises = r.ExerciseFile.Select(e => new ExerciseViewModel { Id = e.Id, Name = e.Name }), Images = r.Image.Select(e => new ImageViewModel { Id = e.Id, Name = e.Name }) }) }; return(View(viewModel)); }