Ejemplo n.º 1
0
        public static async Task <StarWarsPlanets> HttpGetCurrentPlanet(string url)
        {
            string result = null;

            using (HttpClient syncClient = new HttpClient())
            {
                var response = await syncClient.GetAsync(url);

                result = await response.Content.ReadAsStringAsync();
            }

            StarWarsPlanets starWarsPlanets = JsonConvert.DeserializeObject <StarWarsPlanets>(result);

            return(starWarsPlanets);
        }
Ejemplo n.º 2
0
        public async Task DisplayPlanetFile()
        {
            //Task<StarWarsPeople> starWarsPeople = GetJsonFiles.GetPeopleFile();

            StarWarsPlanets starWarsPlanets = await GetJsonFiles.GetPlanetFile();

            List <StarWarsPeople> starWarsPlanets = new List <StarWarsPeople>();

            starWarsPlanets.Add(starWarsPlanets);

            dataGridView_swDB.DataSource = new BindingList <StarWarsPeople>(starWarsPlanets);

            var bindingList = new BindingList <StarWarsPeople>(starWarsPlanets);
            var source      = new BindingSource(bindingList, null);
        }
Ejemplo n.º 3
0
        public static async Task <StarWarsPlanets> GetPlanetFile()
        {
            string url;

            StringBuilder sb = new StringBuilder();

            sb.Clear();
            sb.Append("https://swapi.co/api/people/1/?format=json");

            url = sb.ToString();

            StarWarsPlanets starWarsPlanets = new StarWarsPlanets();

            Task <StarWarsPlanets> getSWPlanets = HttpGetCurrentPlanet(url);

            getSWPlanets.Wait();

            starWarsPlanets = await getSWPlanets;

            return(starWarsPlanets);
        }
Ejemplo n.º 4
0
        private void moreInfo_btn_Click(object sender, EventArgs e)
        {
            if (dataGridView_swDB.SelectedRows.Count == 1)
            {
                if (dataGridView_swDB.GetType() == typeof(StarWarsPeople))
                {
                    StarWarsPeople swPeople = new StarWarsPeople();
                    swPeople = (StarWarsPeople)dataGridView_swDB.CurrentRow.DataBoundItem;

                    DetailFormPlanets detailFormPeople = new DetailFormPlanets(swPeople);
                    detailFormPeople.ShowDialog();
                }
                else if (dataGridView_swDB.GetType() == typeof(StarWarsPlanets))
                {
                    StarWarsPlanets swPlanets = new StarWarsPlanets();
                    swPlanets = (StarWarsPlanets)dataGridView_swDB.CurrentRow.DataBoundItem;

                    DetailFormPlanets detailFormPlanets = new DetailFormPlanets(swPlanets);
                    detailFormPlanets.ShowDialog();
                }
            }
        }