예제 #1
0
        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);
            }
        }
예제 #2
0
 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);
     }
 }