private async void Menu2_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 <Cafe> lstCafe = new List <Cafe>(); for (int i = 0; i < obj.Cafe.Count; i++) { Cafe c = new Cafe(); c.title = obj.Cafe[i].title.ToString(); c.description = obj.Cafe[i].description.ToString(); lstCafe.Add(c); } GridView gvCafe = Comun.FindChildControl <GridView>(HubPrincipal, "gvCafe") as GridView; gvCafe.ItemsSource = lstCafe.ToList(); List <OtrasBebidas> lstOtrasBebidas = new List <OtrasBebidas>(); for (int i = 0; i < obj.OtrasBebidas.Count; i++) { OtrasBebidas ob = new OtrasBebidas(); ob.title = obj.OtrasBebidas[i].title.ToString(); ob.description = obj.OtrasBebidas[i].description.ToString(); lstOtrasBebidas.Add(ob); } GridView gvotrasBebidas = Comun.FindChildControl <GridView>(HubPrincipal, "gvOtrasBebidas") as GridView; gvotrasBebidas.ItemsSource = lstOtrasBebidas.ToList(); } catch (Exception error) { Windows.UI.Popups.MessageDialog msg = new Windows.UI.Popups.MessageDialog(error.ToString()); var resp = msg.ShowAsync(); } }
private async void Menu2_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<Cafe> lstCafe = new List<Cafe>(); for (int i = 0; i < obj.Cafe.Count; i++) { Cafe c = new Cafe(); c.title = obj.Cafe[i].title.ToString(); c.description = obj.Cafe[i].description.ToString(); lstCafe.Add(c); } GridView gvCafe = Comun.FindChildControl<GridView>(HubPrincipal, "gvCafe") as GridView; gvCafe.ItemsSource = lstCafe.ToList(); List<OtrasBebidas> lstOtrasBebidas = new List<OtrasBebidas>(); for (int i = 0; i < obj.OtrasBebidas.Count; i++) { OtrasBebidas ob = new OtrasBebidas(); ob.title = obj.OtrasBebidas[i].title.ToString(); ob.description = obj.OtrasBebidas[i].description.ToString(); lstOtrasBebidas.Add(ob); } GridView gvotrasBebidas = Comun.FindChildControl<GridView>(HubPrincipal, "gvOtrasBebidas") as GridView; gvotrasBebidas.ItemsSource = lstOtrasBebidas.ToList(); } catch (Exception error) { Windows.UI.Popups.MessageDialog msg = new Windows.UI.Popups.MessageDialog(error.ToString()); var resp = msg.ShowAsync(); } }