public IActionResult JoinMatch(int id) { User user = null; if (int.TryParse(HttpContext.User?.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier)?.Value, out int userId)) { user = Database.Users.FirstOrDefault(x => x.Id == userId); } if (user is null) { return(BadRequest("Error find authenticated user")); } var match = Database.Matches.FirstOrDefault(x => x.MatchId == id); return(Ok(_matchService.ConnectToMatch(user.Id, match.MatchId))); }