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