public GameSession JoinRandomGameSession(string token) { using (var _db = new ApplicationDbContext()) { var userGameStorage = new UserGameStorage(); var userManager = new UserManager(); var sessionManager = new SessionManager(); var questionManager = new QuestionManager(); var reusableServices = new ReusableServices(); var question = questionManager.RandomizeQuestion(); var gameSessionsList = _db.GameSessions.Where(c => c.isSessionUsed == false).ToList(); var maxSize = gameSessionsList.Count(); var index = reusableServices.GetNumberForRandomization(0, maxSize - 1); var gameSession = gameSessionsList[index]; gameSession = CreateGameSession(question); var session = sessionManager.GetSession(token); var user = userManager.GetUser(session.UId); userGameStorage.UId = user.ID; userGameStorage.GId = gameSession.Id; //var storage = _UserGameStoreManager.CreateUGS(userGameStorage); return(gameSession); } }
public GameSession GetRandomGameSession() { using (var _db = new ApplicationDbContext()) { ReusableServices reusableServices = new ReusableServices(); var gameSessionsList = _db.GameSessions.Where(c => c.isSessionUsed == false).ToList(); var maxSize = gameSessionsList.Count(); var index = reusableServices.GetNumberForRandomization(0, maxSize - 1); var gameSession = gameSessionsList[index]; return(gameSession); } }