Exemplo n.º 1
0
        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();
            }
            

        }
Exemplo n.º 2
0
        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();
            }
        }