public async Task <TeamDTO> JoinTeam(TeamSignupDTO signupDTO) { var team = await teamRepository.JoinTeam(signupDTO.UserId, signupDTO.TeamCode); if (team == null) { return(null); } return(await GetTeamById(team.Id)); }
public async Task <IActionResult> JoinTeam([FromBody] TeamSignupDTO signupDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var userId = int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value); if (userId != signupDTO.UserId) { return(Forbid()); } var team = await teamService.JoinTeam(signupDTO); if (team == null) { return(NotFound()); } return(Ok(team)); }