public async Task ExecuteAsync(Update update)
        {
            var user = await _registrationService.RegisterIfNotExists(update);

            _logger.LogDebug($"User {update.Message.From.Id} tries to start game");

            user.UserStatus = UserStatus.Player;
            await _usersRepository.UpdateAsync(user);

            await _messageSender.SendTo(user.Id, Resources.GameStarted);

            await _nextQuestionCommand.ExecuteAsync(update);
        }
예제 #2
0
        public async Task ExecuteAsync(Update update)
        {
            var userId = update.Message.From.Id;
            var answer = update.Message.Text.Trim();

            _logger.LogDebug($"User {userId} answers {answer}");

            var userAnswer = (await _userAnswerRepository.FindAsync(x => x.UserId == userId && x.Answer.IsStub))
                             .First();

            var realAnswer = (await _answerRepository.FindAsync(
                                  x => x.Text.Equals(answer, StringComparison.InvariantCultureIgnoreCase)))
                             .First();

            userAnswer.AnswerId = realAnswer.Id;

            _logger.LogDebug($"User answers {realAnswer.Text}");

            await _userAnswerRepository.UpdateAsync(userAnswer);

            await _nextQuestionCommand.ExecuteAsync(update);
        }