public async Task <IActionResult> Index([FromBody] ZipCodeData data)
        {
            if (ModelState.IsValid)
            {
                if (ZipCode.TryParse(data.Value, out ZipCode zipCode))
                {
                    ZipCodeResult zipCodeResult = await ZipCodeLoad.FindAsync(zipCode);

                    return(Json(zipCodeResult));
                }
            }
            return(Json(new { IsValid = false }));
        }
Exemple #2
0
        public async Task <IActionResult> Cep(string cep, ZipCodeLoad zip)
        {
            ZipCodeResult result = await zip.FindAsync(cep);

            ViewData["cep"] = cep;
            if (result.IsValid)
            {
                Cep cepDados = new Cep();
                cepDados.rua    = result.Result.Address;
                cepDados.bairro = result.Result.District;
                cepDados.cidade = result.Result.City;
                cepDados.uf     = result.Result.Uf;
                return(View(cepDados));
            }

            return(View());
        }