private async void Menu4_Loaded(object sender, RoutedEventArgs e) { try{ Uri ruta = new Uri("http://doniaelena.anabiosis.com.mx/menu.json", UriKind.Absolute); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ruta); WebResponse response = await request.GetResponseAsync(); Stream stream = response.GetResponseStream(); string contenido = Comun.LecturaDatos(stream); var obj = JsonConvert.DeserializeObject <RootObject>(contenido); List <AntojosSalados> lstAntojosSalados = new List <AntojosSalados>(); for (int i = 0; i < obj.AntojosSalados.Count; i++) { AntojosSalados aS = new AntojosSalados(); aS.title = obj.AntojosSalados[i].title.ToString(); aS.description = obj.AntojosSalados[i].description.ToString(); lstAntojosSalados.Add(aS); } GridView gvAntojosSalados = Comun.FindChildControl <GridView>(HubPrincipal, "gvAntojosSalados") as GridView; gvAntojosSalados.ItemsSource = lstAntojosSalados.ToList(); } catch (Exception error) { Windows.UI.Popups.MessageDialog msg = new Windows.UI.Popups.MessageDialog(error.ToString()); var resp = msg.ShowAsync(); } }
async private void getGaleriaJson() { Uri ruta = new Uri("http://divinacocoa.com.mx/beta/api/gallery", UriKind.Absolute); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ruta); WebResponse response = await request.GetResponseAsync(); Stream stream = response.GetResponseStream(); string contenido = Comun.LecturaDatos(stream); contenido = "{results: " + contenido + "}"; var obj = JsonConvert.DeserializeObject <ImageObject>(contenido); List <Imagen> _lstImagen = new List <Imagen>(); for (int i = 0; i < obj.Results.Count; i++) { Imagen img = new Imagen(); img.url = obj.Results[i].url; img.url = imgHost + img.url; _lstImagen.Add(img); } gvGaleria.ItemsSource = _lstImagen; var a = true; }
private async void Menu_Loaded(object sender, RoutedEventArgs e) { try { Uri ruta = new Uri("http://doniaelena.anabiosis.com.mx/menu.json", UriKind.Absolute); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ruta); WebResponse response = await request.GetResponseAsync(); Stream stream = response.GetResponseStream(); string contenido = Comun.LecturaDatos(stream); var obj = JsonConvert.DeserializeObject <RootObject>(contenido); List <ChocolateDeMesa> lstChocolateMesa = new List <ChocolateDeMesa>(); for (int i = 0; i < obj.ChocolateDeMesa.Count; i++) { ChocolateDeMesa cm = new ChocolateDeMesa(); cm.title = obj.ChocolateDeMesa[i].title.ToString(); cm.description = obj.ChocolateDeMesa[i].description.ToString(); lstChocolateMesa.Add(cm); } GridView gvChocolateMesa = Comun.FindChildControl <GridView>(HubPrincipal, "gvChocolateMesa") as GridView; gvChocolateMesa.ItemsSource = lstChocolateMesa.ToList(); List <ChocolateBlanco> lstChocolateBlanco = new List <ChocolateBlanco>(); for (int i = 0; i < obj.ChocolateBlanco.Count; i++) { ChocolateBlanco cb = new ChocolateBlanco(); cb.title = obj.ChocolateBlanco[i].title.ToString(); cb.description = obj.ChocolateBlanco[i].description.ToString(); lstChocolateBlanco.Add(cb); } GridView gvChocolateBlanco = Comun.FindChildControl <GridView>(HubPrincipal, "gvChocolateBlanco") as GridView; gvChocolateBlanco.ItemsSource = lstChocolateBlanco.ToList(); } catch (Exception error) { Windows.UI.Popups.MessageDialog msg = new Windows.UI.Popups.MessageDialog(error.ToString()); var resp = msg.ShowAsync(); } }