public async Task <ActionResult <CustomerAddressViewModel> > GetByName([FromQuery] CustomerNameViewModel customer)
        {
            var customerVM = await _customerService.GetAddressByNameAsync(customer);

            if (customerVM == null)
            {
                return(NotFound());
            }

            return(Ok(customerVM));
        }
Exemplo n.º 2
0
        public async Task <CustomerAddressViewModel> GetAddressByNameAsync(CustomerNameViewModel customerVM)
        {
            var customer = _mapper.Map <CustomerAddressViewModel>(await _customerRepository.GetByNameAsync(customerVM.Name));

            if (customer != null)
            {
                var address = await _viaCEPService.GetByCEPAsync(customer.CEP);

                customer.Address.Id         = customer.AddressId;
                customer.Address.Street     = address?.Street;
                customer.Address.StreetFull = address?.StreetFull;
                customer.Address.UF         = address?.UF;
            }

            return(customer);
        }
Exemplo n.º 3
0
        public async Task <CustomerAddressViewModel> GetAddressByNameAsync(CustomerNameViewModel customerVM)
        {
            var customer = _mapper.Map <CustomerAddressViewModel>(await _customerRepository.GetByNameAsync(customerVM.Name));

            if (customer != null)
            {
                var address = await _viaCEPService.GetByCEPAsync(customer.CEP);

                customer.Address.Id          = customer.AddressId;
                customer.Address.Localidade  = address?.Localidade;
                customer.Address.Logradouro  = address?.Logradouro;
                customer.Address.Complemento = address?.Complemento;
                customer.Address.Bairro      = address?.Bairro;
                customer.Address.UF          = address?.UF;
            }

            return(customer);
        }