Ejemplo n.º 1
0
        public async Task <int> FindCep()
        {
            var find = CEP.Text.Trim();

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

            if (isValidCep(find))
            {
                try
                {
                    var addressRepositories = await GetAddressBase();

                    Address result = ViaCepService.FindAdressViaCep(find);

                    if (!addressRepositories.Contains((object)result))
                    {
                        var task = await SaveAddressBase(new AddressRepository(result.Cep, result.Logradouro, result.Bairro, result.Logradouro, result.Uf));
                    }


                    RESULT.Text = string.Format(" Endereço:\n {0}\n {1}\n {2}\n {3}\n {4}\n", result.Cep, result.Logradouro, result.Bairro, result.Localidade, result.Uf);
                    return(1);
                }
                catch (Exception e)
                {
                    DisplayAlert("Erro:", e.Message, "OK");
                }
            }

            return(0);
        }