public async Task <ActionResult <IEnumerable <AssignmentDto> > > GetLessonAssignments( [FromRoute] Guid classroomId, [FromRoute] Guid lessonId ) { var user = (ApplicationUser)HttpContext.Items["ApplicationUser"]; Debug.Assert(user != null, nameof(user) + " != null"); try { var classroom = await _classroomService.FindAsync(classroomId); var authorization = await _authorizationService.AuthorizeAsync(User, classroom, "IsInClassroom"); if (!authorization.Succeeded) { return(Forbid()); } var lesson = await _lessonService.FindAsync(lessonId); var assignments = await _assignmentService.FindByLessonAsync(lesson); return(Ok(assignments.Select(a => a.ToDto()))); } catch (Exception e) { Console.WriteLine(e); return(BadRequest()); } }