コード例 #1
0
        public Task <bool> Handle(InactivateGameCommand command, CancellationToken cancellationToken)
        {
            if (!command.IsValid())
            {
                NotifyValidationErrors(command);
                return(Task.FromResult(false));
            }

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

            if (!game.Active)
            {
                mediator.RaiseEventAsync(new DomainNotification(command.MessageType, "O jogo já esta inativo!"));
                return(Task.FromResult(false));
            }

            game.InActivate();

            gameWriteRepository.Update(game);

            if (Commit())
            {
                mediator.RaiseEventAsync(new InactivateGameEvent(game.Id));
            }

            return(Task.FromResult(true));
        }
コード例 #2
0
ファイル: GameService.cs プロジェクト: Gasma/GasmaLend
        public void Inactivate(Guid id)
        {
            var command = new InactivateGameCommand(id);

            mediator.SendCommandAsync(command);
        }