Example #1
0
        private void BuscarCep(object sender, EventArgs args)
        {
            //validate

            //logica

            //search
            string cep = InputCep.Text.Trim();

            cep = cep.Replace("-", "");

            if (IsValidCep(cep))
            {
                try
                {
                    Endereco end = ViaCepServico.BuscarCep(cep);
                    if (end != null)
                    {
                        lbl_result.Text = string.Format("Endereço: {2}, {3}, {0} , {1}, {2}", end.localidade, end.uf, end.logradouro, end.bairro);
                    }
                    else
                    {
                        DisplayAlert("ERRO", "CEP não encontrado, verifique o CEP e tente novamente", "OK");
                    }
                }
                catch (Exception ex)
                {
                    DisplayAlert("ERRO", "O serviço de busca está indisponível./nCódigo do Erro:" + ex.Message, "OK");
                }
            }
            else
            {
                lbl_result.Text = "O CEP digitado é inválido.";
            }
        }