public IHttpActionResult JoinRandomChat(string token) { var userManager = new UserManager(); var gameSession = new GameSession(); var sessionManager = new SessionManager(); var questionManager = new QuestionManager(); try { gameSession = _GameSessionManager.GetRandomGameSession(); ++gameSession.PlayerCount; _GameSessionManager.UpdateGameSession(gameSession); var session = sessionManager.GetSession(token); var user = userManager.GetUser(session.UId); var userGameStorage = new UserGameStorage() { UId = user.ID, GId = gameSession.Id }; var storage = _UserGameStoreManager.CreateUGS(userGameStorage); var userTeam = _GameMan.AssignPlayer(user.SsoId); var gameSessionDTO = new GameSessionDTO() { Token = gameSession.Token, Question = questionManager.GetQuestion(gameSession.QuestionID).QuestionString, IsSessionUsed = gameSession.isSessionUsed, PlayerCount = gameSession.PlayerCount, GameRole = user.Role, Order = userGameStorage.Order }; return(Ok(gameSessionDTO)); } catch (Exception e) { return(Content(HttpStatusCode.BadRequest, e.ToString())); } }