예제 #1
0
        public async Task <object> ObterDependente(Guid clienteId)
        {
            var obterDependenteCommand  = new ObterDependenteCommand(clienteId);
            var obterDependenteResponse = await _bus.SendCommand(obterDependenteCommand);

            return(_notifications.HasNotifications() ? obterDependenteResponse : _mapper.Map <IEnumerable <DependenteViewModel> >((IEnumerable <ClienteDependente>)obterDependenteResponse));
        }
예제 #2
0
        public async Task <object> Handle(ObterDependenteCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(await Task.FromResult(false));
            }

            var cliente = _clienteRepository.GetById(message.ClienteId);

            if (cliente == null)
            {
                await _bus.RaiseEvent(new DomainNotification(message.MessageType, "Cliente não cadastrado.", message));

                return(await Task.FromResult(false));
            }

            return(await Task.FromResult(cliente.Dependentes));
        }