public Task <bool> Handle(DeletarEnderecoCommand message, CancellationToken cancellationToken) { if (!message.IsValid()) { NotifyValidationErrors(message); return(Task.FromResult(false)); } var onboarding = _onboardingRepository.Find(o => o.CodigoConvite.Equals(message.CodigoConvite) && o.NumeroCelular.Equals(message.NumeroCelular)).FirstOrDefault(); if (onboarding == null) { _bus.RaiseEvent(new DomainNotification(message.MessageType, "Código do convite ou número de celular inválidos.", message)); return(Task.FromResult(false)); } if (onboarding.Consultor == null) { _bus.RaiseEvent(new DomainNotification(message.MessageType, "Consultor não cadastrado.", message)); return(Task.FromResult(false)); } var endereco = _enderecoRepository.GetById(message.EnderecoId); if (endereco != null) { _enderecoRepository.Remove(message.EnderecoId); if (Commit()) { } return(Task.FromResult(true)); } _bus.RaiseEvent(new DomainNotification(message.MessageType, "Endereço não encontrado.", message)); return(Task.FromResult(false)); }
public void DeletarEndereco(string codigoConvite, string numeroCelular, Guid enderecoId) { var deletarEnderecoCommand = new DeletarEnderecoCommand(codigoConvite, numeroCelular, enderecoId); _bus.SendCommand(deletarEnderecoCommand); }