public async Task <ActionResult <Project> > GetBuilderProject(string builderId) { var currentUserId = User.Identity.Name; Project result; try { if (User.IsInRole(Role.Admin)) { result = await _buildersService.GetBuilderProjectFromAdminAsync(builderId); } else if (User.IsInRole(Role.Coach)) { result = await _buildersService.GetBuilderProjectFromCoachAsync(currentUserId, builderId); } else if (User.IsInRole(Role.Builder)) { result = await _buildersService.GetBuilderProjectFromBuilderAsync(currentUserId, builderId); } else { return(Forbid("You must be part of the Buildup program")); } } catch (UnauthorizedAccessException e) { return(Forbid($"You are not allowed to see this project: {e.Message}")); } catch (Exception e) { return(BadRequest($"Can't get the builder's project: {e.Message}")); } if (result == null) { return(NotFound()); } return(Ok(result)); }