public JsonResult Cidades(string uf) { var cidades = from c in MunicipioService.GetByUf(uf) select new { Text = c.Nome, Value = c.Codigo }; return(Json(cidades.ToArray(), JsonRequestBehavior.AllowGet)); }
public async void ApiMunicipio(string token) { MunicipioApi municipioapi = new MunicipioApi(); MunicipioService service = new MunicipioService(); Municipio municipio = new Municipio(); string respm = string.Empty; try { var client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var endereco = Settings.EnderecoApi; client.BaseAddress = new Uri(endereco); var url = "cidade/obter-cidades-da-bahia"; var resultm = await client.GetAsync(url); if (!resultm.IsSuccessStatusCode) { throw new Exception(resultm.RequestMessage.Content.ToString()); } respm = await resultm.Content.ReadAsStringAsync(); } catch (Exception ex) { await DisplayAlert("Erro", ex.Message, "Ok"); } municipioapi = JsonConvert.DeserializeObject <MunicipioApi>(respm); /*foreach (var obj in municipioapi.data) * { * Console.WriteLine(obj.nome); * }*/ for (int i = 0; i < municipioapi.data.Count; i++) { municipio.Id = municipioapi.data[i].id; municipio.NomeMunicipio = municipioapi.data[i].nome; service.InsertMunicipio(municipio); } }
// POST: api/Municipio public List <Municipio> Post([FromBody] Estado estado) { MunicipioService servicio = new MunicipioService(cadenaConexion); return(servicio.ConsultarMunicipios(estado)); }
public MunicipioController(MunicipioService service) { _service = service; }
public MunicipioController(MunicipioService servico) { _servico = servico; }
private ContaViewModel BuildIndexViewModel() { var model = new ContaViewModel(); ViewBag.ActiveNav = "Minha conta"; /* base model defaults */ model.Title = "Meus dados - Massa News"; model.Description = "Meus dados de cadastro - Massa News"; model.Robots = "noindex, nofollow"; model.Canonical = $"{Constants.UrlWeb}/minha-conta"; model.Usuario = CurrentUser.Data; model.Estados = new List <SelectListItem> { new SelectListItem { Value = "AC", Text = "Acre" }, new SelectListItem { Value = "AL", Text = "Alagoas" }, new SelectListItem { Value = "AP", Text = "Amapá" }, new SelectListItem { Value = "AM", Text = "Amazonas" }, new SelectListItem { Value = "BA", Text = "Bahia" }, new SelectListItem { Value = "CE", Text = "Ceará" }, new SelectListItem { Value = "DF", Text = "Distrito Federal" }, new SelectListItem { Value = "ES", Text = "Espírito Santo" }, new SelectListItem { Value = "GO", Text = "Goiás" }, new SelectListItem { Value = "MA", Text = "Maranhão" }, new SelectListItem { Value = "MT", Text = "Mato Grosso" }, new SelectListItem { Value = "MS", Text = "Mato Grosso do Sul" }, new SelectListItem { Value = "MG", Text = "Minas Gerais" }, new SelectListItem { Value = "PA", Text = "Pará" }, new SelectListItem { Value = "PB", Text = "Paraíba" }, new SelectListItem { Value = "PR", Text = "Paraná" }, new SelectListItem { Value = "PE", Text = "Pernambuco" }, new SelectListItem { Value = "PI", Text = "Piauí" }, new SelectListItem { Value = "RJ", Text = "Rio de Janeiro" }, new SelectListItem { Value = "RN", Text = "Rio Grande do Norte" }, new SelectListItem { Value = "RS", Text = "Rio Grande do Sul" }, new SelectListItem { Value = "RO", Text = "Rondônia" }, new SelectListItem { Value = "RR", Text = "Roraima" }, new SelectListItem { Value = "SC", Text = "Santa Catarina" }, new SelectListItem { Value = "SP", Text = "São Paulo" }, new SelectListItem { Value = "SE", Text = "Sergipe" }, new SelectListItem { Value = "TO", Text = "Tocantins" }, }; if (!string.IsNullOrEmpty(model.Usuario.Estado) && !string.IsNullOrEmpty(model.Usuario.Cidade)) { model.Cidades = (from c in MunicipioService.GetByUf(model.Usuario.Estado) select new SelectListItem { Value = c.Codigo.ToString(), Text = c.Nome, }).ToList(); } else { model.Cidades = new List <SelectListItem>(); } model.Sexos = new List <SelectListItem> { new SelectListItem { Value = "M", Text = "Masculino" }, new SelectListItem { Value = "F", Text = "Feminino" }, }; return(model); }