示例#1
0
        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();
            }
        }
示例#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();
            }
        }