Ejemplo n.º 1
0
 static LaunchController()
 {
     Launches = doTheScrape().Result;
     foreach (var item in Launches.launches)
     {
         CleanDataLaunches.Add(new Models.CleanData.MainLaunch(item));
     }
 }
Ejemplo n.º 2
0
        static async Task <Models.RawData.Launches> doTheScrape()
        {
            using (var client = new HttpClient())
            {
                try
                {
                    client.BaseAddress = new Uri("https://launchlibrary.net/1.4/");
                    var response = await client.GetAsync($"launch/next/100");

                    response.EnsureSuccessStatusCode();

                    var stringResult = await response.Content.ReadAsStringAsync();

                    Models.RawData.Launches rawWeather = JsonConvert.DeserializeObject <Models.RawData.Launches>(stringResult);
                    return(rawWeather);
                }
                catch (HttpRequestException httpRequestException)
                {
                    return(new Models.RawData.Launches());
                }
            }
        }