public async Task <ClimaCity> Get(int id)
        {
            string     url     = "http://api.openweathermap.org/data/2.5/weather?id=" + id + "&appid=410aa6ce7a2e29f13f3b4dd7b9eec4f1";
            HttpClient client  = new HttpClient();
            string     content = await client.GetStringAsync(url);

            ClimaCity posts = JsonConvert.DeserializeObject <ClimaCity>(content);

            return(posts);
        }
Example #2
0
        private ClimaCity GoToData(int city)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:62412/");
                var response = client.GetAsync($"api/services/{city}").Result;
                if (response.IsSuccessStatusCode)
                {
                    var jsonString = response.Content.ReadAsStringAsync();
                    jsonString.Wait();
                    dataClimaCity = JsonConvert.DeserializeObject <ClimaCity>(jsonString.Result);
                }
            }

            return(dataClimaCity);
        }