public ActionResult Weather() { WeatherLogClient client = new WeatherLogClient(); var model = client.Get(DateTime.Today.Month, DateTime.Today.Year); return(View(model)); }
public void Start() { HttpClient client = new HttpClient(); string json = client.GetStringAsync("http://api.openweathermap.org/data/2.5/weather?id=146286&units=metric").Result; Rootobject obj = Newtonsoft.Json.JsonConvert.DeserializeObject <Rootobject>(json); WeatherLogClient logClient = new WeatherLogClient(); WeatherLog log = new WeatherLog(DateTime.Now) { Clouds = obj.clouds.all, Description = obj.weather.FirstOrDefault().description, Humidty = obj.main.humidity, Pressure = obj.main.pressure, Rain = obj.rain._3h, Sunrise = obj.sys.sunrise, Sunset = obj.sys.sunset, Temperature = obj.main.temp, WindDegree = obj.wind.deg, WindSpeed = obj.wind.speed, CityId = obj.id }; logClient.InsertOrReplace(log); }