public ActionResult Index(ListaLocal LL) { if (LL.NumLocal != null && LL.NumLocal.Trim().Length > 0) { LL.ResultLocal = db.ListaLocal("%" + LL.NumLocal.Trim() + "%").OrderBy(L => L.Descripcion).ToList(); } else { LL.ResultLocal = db.ListaLocal("%").OrderBy(L => L.Descripcion).ToList(); } return(View(LL)); }
// GET: /Local/ public ActionResult Index() { if (User.Identity.IsAuthenticated) { if (!User.IsInRole("ROLLTRA")) { RedirectToAction("AccesoDenegado", "Acceso"); } } else { RedirectToAction("~/Account/Login"); } ListaLocal LL = new ListaLocal(); LL.ResultLocal = db.ListaLocal("%").OrderBy(L => L.Descripcion).ToList(); return(View(LL)); }
private async Task RequestPokemons(string byUrl = "") { //await Task.Delay(5000); ProgressDialog pbar = new ProgressDialog(this); pbar.SetCancelable(false); pbar.SetMessage("Buscando Informações..."); pbar.SetProgressStyle(ProgressDialogStyle.Horizontal); pbar.Indeterminate = true; pbar.SetProgressStyle(ProgressDialogStyle.Spinner); pbar.Show(); //new Thread(new ThreadStart(async delegate //{ try { fLista.Clear(); Filtrar(); await Task.Delay(3000); using (var client = new HttpClient()) { // envia a requisição GET //var response = await client.GetStringAsync("https://pokeapi.co/api/v2/pokemon/").ConfigureAwait(true); string response; if (byUrl == "") { response = await client.GetStringAsync("https://pokeapi.co/api/v2/pokemon/?limit=25").ConfigureAwait(true); } else { response = await client.GetStringAsync(byUrl).ConfigureAwait(true); } // processa a resposta GetPokemon getPokemon = JsonConvert.DeserializeObject <GetPokemon>(response); fAnt = ""; fNext = ""; if (!string.IsNullOrEmpty(getPokemon.Previous)) { fAnt = getPokemon.Previous; } if (!string.IsNullOrEmpty(getPokemon.Next)) { fNext = getPokemon.Next; } fLista = new List <ListaLocal>(); foreach (var result in getPokemon.Results) { ListaLocal lista = new ListaLocal(); lista.Name = result.name; response = await client.GetStringAsync("http://pokeapi.co/api/v1/pokemon/" + result.name + "/").ConfigureAwait(true); GetPokemonItem getPokemonItem = JsonConvert.DeserializeObject <GetPokemonItem>(response); if (getPokemonItem != null) { lista.Image = getPokemonItem.Sprites.front_default; lista.Id = getPokemonItem.Id; lista.Height = getPokemonItem.Height; lista.Weight = getPokemonItem.Weight; foreach (var tipo in getPokemonItem.Types) { List <PokemonType> pokemonTypes = new List <PokemonType>(); pokemonTypes.Add(new PokemonType { slot = tipo.slot, type = new NameAPIResource { name = tipo.type.name, url = tipo.type.url } }); lista.Types = pokemonTypes; } } fLista.Add(lista); } } } catch (Exception ex) { Thread.Sleep(1000); this.RunOnUiThread(() => { this.Window.AddFlags(WindowManagerFlags.NotTouchable | WindowManagerFlags.NotTouchable); }); } RunOnUiThread(() => { Filtrar(); pbar.Cancel(); return; }); //})).Start(); }