public static bool PossuiEnderecoInformado(this RemoveClienteCommand command, IClienteRepository clienteRepository) { var cliente = clienteRepository.ObterPorId(command.ClienteId); return(AssertionConcern.IsSatisfiedBy( AssertionConcern.AssertTrue(cliente.Enderecos.Count == 0, "Cliente possui endereços. Não será possível excluir.") )); }
public ICommandResult Handle(RemoveClienteCommand command) { if (!command.PossuiEnderecoInformado(_clienteRepository)) { return(new ClienteCommandResult()); } _clienteRepository.Remover(command.ClienteId); return(new ClienteCommandResult()); }
public void Remover(Guid id) { //**ANTES //BeginTransaction(); //_clienteService.Remover(id); //Commit(); //**DEPOIS var clienteCommand = new RemoveClienteCommand(id); var result = _handlerRemoveCliente.Handle(clienteCommand); Commit(); }
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)); }
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()); }
public void Remove(Guid id) { var removeCommand = new RemoveClienteCommand(id); Bus.SendCommand(removeCommand); }
public async Task Remove(Guid id) { var command = new RemoveClienteCommand(id); await _mediator.SendCommand(command); }
public async Task <ValidationResult> Remove(Guid id) { var removeCommand = new RemoveClienteCommand(id); return(await _mediator.SendCommand(removeCommand)); }