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

            _clienteRepository.Remove(message.Id);

            if (Commit())
            {
                Bus.RaiseEvent(new ClienteRemovedEvent(message.Id));
            }

            return(Task.FromResult(true));
        }
Beispiel #2
0
        public Task Handle(RemoveClienteCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.CompletedTask);
            }

            _clienteRepository.Remove(message.Id);

            if (Commit())
            {
                Bus.RaiseEvent(new ClienteRemovedEvent(message.Id));
            }

            return(Task.CompletedTask);
        }
        public Task <CommandResult> Handle(RemoveClienteCommand command, CancellationToken cancellationToken)
        {
            if (!command.IsValid())
            {
                NotifyCommandErrors(command);
                return(Response());
            }

            Cliente cliente = _clienteRepository.GetById(command.Id);

            _clienteRepository.Remove(cliente);

            if (Commit())
            {
                _mediator.PublishEvent(new RemovedClienteEvent(cliente));
            }

            return(Response());
        }