Beispiel #1
0
        public void Handle(JoinGameCommand command)
        {
            var gameId    = GameId.NewGameId(command.GameId);
            var playerId  = PlayerId.NewPlayerId(command.PlayerId);
            var joinEvent = Domain.Game.join(playerId, command.PlayerName);

            eventStore.Add(gameId, joinEvent);
        }
Beispiel #2
0
        public void Handle(AnswerSingleAnswerQuestionCommand command)
        {
            var gameId   = GameId.NewGameId(command.GameId);
            var playerId = PlayerId.NewPlayerId(command.PlayerId);
            var optionId = OptionId.NewOptionId(command.OptionId);

            var game        = gameRepository.GetById(gameId);
            var answerEvent = Domain.Game.answerQuestion(
                game,
                playerId,
                DomainTypes.Answer.NewSingleAnswer(
                    new DomainTypes.SingleAnswer(
                        optionId)));

            if (answerEvent != null)
            {
                eventStore.Add(gameId, answerEvent.Value);
            }
        }