示例#1
0
        protected Dictionary <string, string> ValidaLocalizacao(int idEndGeoCidade, int idEndGeoEstado)
        {
            var retorno = new Dictionary <string, string>();

            var cidade = new GeoCidadeSelect().GetById(idEndGeoCidade).FirstOrDefault();

            if (cidade == null)
            {
                Add(new DomainNotification("CEP", "Cidade e Estado não localizados."));
            }
            else
            {
                if (cidade.IdGeoEstado != idEndGeoEstado)
                {
                    Add(new DomainNotification("CEP", "Cidade e Estado não localizados."));
                }
                else
                {
                    var estado = new GeoEstadoSelect().GetById(idEndGeoEstado);

                    if (estado == null)
                    {
                        Add(new DomainNotification("CEP", "Cidade e Estado não localizados."));
                    }
                    else
                    {
                        retorno.Add("estado", estado.Sigla);
                        retorno.Add("cidade", cidade.Nome);
                    }
                }
            }

            return(retorno);
        }
        public IActionResult EdtAdvEndereco(int id, int idAdv)
        {
            var model = new AdvogadoEnderecoSelect().GetModel(idAdv, UserId, id) ?? new AdvogadoEnderecoModel()
            {
                IdAdvogado = idAdv
            };

            var estados = new GeoEstadoSelect().Get().ToList();

            ViewBag.Estados = estados;

            if (model.IdEnd != 0)
            {
                ViewBag.Cidades = new GeoCidadeSelect().Get(model.IdEndGeoEstado).ToList();
            }
            else
            {
                ViewBag.Cidades = new GeoCidadeSelect().Get(estados.Any() ? estados.FirstOrDefault().Id : 0).ToList();
            }

            ViewBag.TipoEndereco = new TipoEnderecoSelect().Get().ToList();

            return(PartialView("Advogado/Endereco/_EdtPartial", model));
        }