public async Task <IActionResult> ChangeYouTubeAccount([FromBody] EditYouTubeIdRequest request) { int currentUserId = User.GetUserId(); if (currentUserId != request.TeamMemberId && !User.IsInRole(AuthConstants.ADMIN_ROLE)) { throw new ForbiddenException("Can't edit this user data!"); } if (memberService.GetTeamMemberOrNullAsync(currentUserId) == null) { throw new BadRequestException("The user need to belong to a team first!"); } string channelId; if (string.IsNullOrWhiteSpace(request.ChannelUrl)) { channelId = null; } else { channelId = await youTubeService.GetUserIdAsync(request.ChannelUrl); } await memberService.ChangeYouTubeChannelIdAsync(request.TeamMemberId, channelId); return(Ok()); }