private async void BuscarCepAsync(object sender, EventArgs args) { var cep = (Cep.Text ?? String.Empty).Trim(); if (CepEhValido(cep)) { try { var end = await CepService.ObterPorCep(cep); if (end != null) { Resultado.Text = $"Endereço: {end.Logradouro}\nBairro: {end.Bairro}\nCidade: {end.Localidade} \nEstado: {end.Uf} "; } else { await DisplayAlert("DEU RUIM", $"O endereço não foi encontrado para o CEP informado: {cep}", "OK"); } } catch (Exception e) { await DisplayAlert("DEU RUIM DEMAIS", e.Message, "OK"); } } }
private void SearchCEP(object sender, EventArgs args) { String cep = lbCep.Text.Trim(); if (isValidCEP(cep)) { try { Address address = CepService.SearchAddressCEP(cep); if (address != null) { lbResultado.Text = string.Format("Endereco: {0} \nBairro: {1} \nCidade: {2} \nEstado: {3}", address.logradouro, address.bairro, address.localidade, address.uf); } else { DisplayAlert("ERRO", "Endereço não encontrado para o cep informado: " + cep, "Ok"); } } catch (Exception e) { DisplayAlert("ERRO", e.Message, "Ok"); } } }
async Task BuscaCep() { if (string.IsNullOrWhiteSpace(lblCep.Text)) { await DisplayAlert("Alerta!", "Digite o Cep para procurar.", "OK"); return; } IsBusy = true; CepService srvCep = new CepService(); CepModel cep = new CepModel(); cep = await srvCep.BuscaCep(lblCep.Text); IsBusy = false; if (cep.Cep == null) { await DisplayAlert("Alerta!", "Falha ao procurar o Cep.", "OK"); return; } else { lblEndereco.Text = cep.Logradouro; lblMunicipio.Text = cep.Localidade; lblEstado.Text = cep.UF; lblBairro.Text = cep.Bairro; lblComplemento.Text = cep.Complemento; } }
public async Task RequisicaoCEP() { ProgressBar.Visibility = ViewStates.Visible; var cepService = new CepService <ModelCEP>(EtCep.Text.ToString()); var retornoRequisicao = await cepService.Consultar(null, null); if (retornoRequisicao != null) { if (retornoRequisicao.Erro) { ProgressBar.Visibility = ViewStates.Gone; Toast.MakeText(this, CepInvalido, ToastLength.Short).Show(); } else { ProgressBar.Visibility = ViewStates.Gone; PopularDados(retornoRequisicao); } } else { ProgressBar.Visibility = ViewStates.Gone; Toast.MakeText(this, OcorreuErro, ToastLength.Short).Show(); } }
public NewItemViewModel() { Title = "New Item Page"; _cepService = new CepService(); SaveItemCommand = new Command(SaveItemAsync); SearchCepCommand = new Command(SearchCepAsync); }
private void OnSearchCep(object sender, EventArgs e) { string cep = Cep.Text; if (IsValidCep(cep)) { Address address = CepService.FindAddressByCep(cep); Result.Text = JsonConvert.SerializeObject(address); } }
private void btn_buscar_Click(object sender, EventArgs e) { CepService cepService = new CepService(); string enderecoFormatado = ""; var endereco = cepService.buscarEndereco(txt_cep.Text); if (!string.IsNullOrEmpty(endereco.cep)) { enderecoFormatado = $"Rua: {endereco.logradouro},\r\nBairro: {endereco.bairro},\r\nEstado: {endereco.uf},\r\nCep: {endereco.cep}"; } txt_resultado.Text = enderecoFormatado; txt_cep.Clear(); }
public CepTest() { this.cepService = new CepService(); }
public PessoasController(PessoaService pessoaService, CepService cepService) { _pessoaService = pessoaService; _cepService = cepService; }
public CepsController(CepService cepService, IConfiguration configuration) { _config = configuration; _cepService = cepService; }
public PeopleController(PeopleService peopleService, CepService cepService) { _peopleService = peopleService; _cepService = cepService; }
public Endereco PesquisarCep(string cep) { var cepService = new CepService(cep); return(cepService.Pesquisar()); }
public CepsController(CepService cepService) { _cepService = cepService; }