public Task <CommandResult> Handle(AddChequeCommand command, CancellationToken cancellationToken) { if (!command.IsValid()) { NotifyCommandErrors(command); return(Response()); } if (_chequeRepository.CheckNumeroChequeExists(command.NumeroCheque, command.ClienteId, command.BancoId, command.Id)) { NotifyCommandError(RequestErrorsMessageConstants.ChequeAlreadyExists); return(Response()); } Banco banco = _bancoRepository.GetById(command.BancoId, loadRelatedData: false); Cliente cliente = _clienteRepository.GetById(command.ClienteId, loadRelatedData: false); Cheque cheque = new Cheque(banco, command.Agencia, command.Conta, command.NumeroCheque, cliente, command.DataEmissao, command.DataVencimento, command.Valor); _chequeRepository.Add(cheque); if (Commit()) { _mediator.Publish(new AddedChequeEvent()); } return(Response()); }