Beispiel #1
0
        public Task <bool> Handle(LendGameCommand command, CancellationToken cancellationToken)
        {
            if (!command.IsValid())
            {
                NotifyValidationErrors(command);
                return(Task.FromResult(false));
            }

            var game = gameReadRepository.GetById(command.Id);

            game.Lend(command.PersonId.Value);

            gameWriteRepository.Update(game);

            if (Commit())
            {
                mediator.RaiseEventAsync(new LendGameEvent(game.Id, game.PersonId.Value));
            }

            return(Task.FromResult(true));
        }