public async Task <ActionResult <CustomerAddressViewModel> > GetById([FromQuery] CustomerIdViewModel customer) { var customerVM = await _customerService.GetAddressByIdAsync(customer); if (customerVM == null) { return(NotFound()); } return(Ok(customerVM)); }
public async Task <ActionResult> DeleteCustomer([FromQuery] CustomerIdViewModel customer) { var customerVM = await _customerService.GetByIdAsync(customer); if (customerVM == null) { return(NotFound()); } _customerService.Remove(customerVM); return(NoContent()); }
public async Task <CustomerAddressViewModel> GetAddressByIdAsync(CustomerIdViewModel customerVM) { var customer = _mapper.Map <CustomerAddressViewModel>(await _customerRepository.GetAddressByIdAsync(customerVM.Id)); 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); }
public async Task <CustomerAddressViewModel> GetAddressByIdAsync(CustomerIdViewModel customerVM) { var customer = _mapper.Map <CustomerAddressViewModel>(await _customerRepository.GetAddressByIdAsync(customerVM.Id)); 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); }
public async Task <CustomerViewModel> GetByIdAsync(CustomerIdViewModel customerVM) { return(_mapper.Map <CustomerViewModel>(await _customerRepository.GetByIdAsync(customerVM.Id))); }