Example #1
0
        public ActionResult Edit([Bind(Include = "END_ID,USU_ID,END_LOGRADOURO,END_NR,END_CIDADE,END_BAIRRO,END_CEP")] EnderecoModel eNDERECO)
        {
            string addrres = eNDERECO.END_LOGRADOURO + ", " + eNDERECO.END_NR + ", " + eNDERECO.END_CIDADE + ", " + eNDERECO.END_BAIRRO;

            var destination_latLong = GoogleGeoCorder.GetLatLongByAddress(addrres);

            //string lat = Convert.ToString(destination_latLong.results[0].geometry.location.lat, CultureInfo.InvariantCulture);

            //string lng = Convert.ToString(destination_latLong.results[0].geometry.location.lng, CultureInfo.InvariantCulture);

            eNDERECO.END_LATITUDE  = "-1.29267215";
            eNDERECO.END_LONGITUDE = "-48.47828597";

            if (ModelState.IsValid)
            {
                try
                {
                    enderecoDominio.alterar(eNDERECO);

                    return(RedirectToAction("Principal", "Home", new { usu_id = eNDERECO.USU_ID }));
                }
                catch (Exception e)
                {
                    mensagem = MensagemTela.erro("erro no sistema: " + e);
                    return(View());
                }
            }
            else
            {
                return(View(eNDERECO));
            }
        }
Example #2
0
        public ActionResult Create([Bind(Include = "USU_ID,END_NR,END_BAIRRO,END_CEP,END_LOGRADOURO,END_CIDADE")] EnderecoModel eNDERECO)
        {
            eNDERECO.USU_ID = usuarioLogado.USU_ID;

            string addrres = eNDERECO.END_LOGRADOURO + ", " + eNDERECO.END_NR + ", " + eNDERECO.END_CIDADE + ", " + eNDERECO.END_BAIRRO;

            var destination_latLong = GoogleGeoCorder.GetLatLongByAddress(addrres);

            //string lat = Convert.ToString(destination_latLong.results[0].geometry.location.lat, CultureInfo.InvariantCulture);

            //string lng = Convert.ToString(destination_latLong.results[0].geometry.location.lng, CultureInfo.InvariantCulture);

            eNDERECO.END_LATITUDE  = "0";
            eNDERECO.END_LONGITUDE = "0";

            if (ModelState.IsValid)
            {
                try
                {
                    enderecoDominio.inserir(eNDERECO);

                    var buscalogin = usuarioDominio.buscaPorId(usuarioLogado.USU_ID);

                    foreach (var item in buscalogin)
                    {
                        eNDERECO.USU_ID = item.USU_ID;
                    }

                    return(RedirectToAction("Principal", "Home", new { usu_id = eNDERECO.USU_ID }));
                }
                catch (Exception e)
                {
                    mensagem = MensagemTela.erro("erro no sistema: " + e);
                    return(View());
                }
            }
            return(View(eNDERECO));
        }