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

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

            if (!game.PersonId.HasValue)
            {
                mediator.RaiseEventAsync(new DomainNotification(command.MessageType, "O jogo não esta emprestado!"));
                return(Task.FromResult(false));
            }

            game.GiveBack();

            gameWriteRepository.Update(game);

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

            return(Task.FromResult(true));
        }
Esempio n. 2
0
        public void GiveBack(Guid id)
        {
            var command = new GiveBackGameCommand(id);

            mediator.SendCommandAsync(command);
        }