public async Task <IActionResult> GetProject([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var project = await _context.Projects.SingleOrDefaultAsync(m => m.Id == id); if (project == null) { return(NotFound()); } try { await EnsureAuthorizedAccessAsync(project); } catch (Exception) { return(Unauthorized()); } var result = ProjectDTO.DbObjectToDto(project); return(Ok(result)); }