Exemplo n.º 1
0
        public ApiResponse CreateGameSession([FromBody] GameSession gameSession, int firstUserId, string rivalUserName, int riddlesCount)
        {
            ApiResponse apiResponse;

            try
            {
                apiResponse = gameSessionService.CreateGameSession(gameSession, firstUserId, rivalUserName, riddlesCount);
            }
            catch (Exception ex)
            {
                apiResponse = new ApiResponse(false, ex.Message);
            }

            return(apiResponse);
        }
Exemplo n.º 2
0
        public async void AcceptInvite(bool accept)
        {
            if (accept)
            {
                var gameSession = await gameSessionService.CreateGameSession(UserProfile.Id, textBox1.Text, level.Id);

                await HubService.StartGame(textBox1.Text, gameSession.Id);

                Playground playground = new Playground(gameSession);
                playground.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show($"Пользователь {textBox1.Text} отклонил ваше приглашение!", "Приглашения", MessageBoxButtons.OK, MessageBoxIcon.Information);
                pictureBox1.Visible = false;
            }
        }
Exemplo n.º 3
0
        public GameSession CreateGameSession(Question question)
        {
            IToken           _tokenService    = new TokenService();
            IQuestionService _questionService = new QuestionService();
            var questionManager = new QuestionManager();

            using (var _db = new ApplicationDbContext())
            {
                GameSession session = new GameSession
                {
                    Token      = _tokenService.GenerateToken(),
                    QuestionID = question.QuestionID
                };
                ++session.PlayerCount;

                _GSessionService.CreateGameSession(_db, session);
                _db.SaveChanges();
                return(session);
            }
        }