diff --git a/WeatherDashboard.Web/Services/WeatherApiForecastService.cs b/WeatherDashboard.Web/Services/WeatherApiForecastService.cs index 51f768a..7f2a2de 100644 --- a/WeatherDashboard.Web/Services/WeatherApiForecastService.cs +++ b/WeatherDashboard.Web/Services/WeatherApiForecastService.cs @@ -28,7 +28,7 @@ namespace WeatherDashboard.Web.Services var url = new UriBuilder(apiBaseUrl); url.Path = method; - url.Query = $"key={apiKey}&q=21144"; + url.Query = $"key={apiKey}&days=10&q=21144"; var response = await httpClient.GetStringAsync(url.ToString()); diff --git a/WeatherDashboard.Web/Views/Home/Index.cshtml b/WeatherDashboard.Web/Views/Home/Index.cshtml index bbe1945..e93c19e 100644 --- a/WeatherDashboard.Web/Views/Home/Index.cshtml +++ b/WeatherDashboard.Web/Views/Home/Index.cshtml @@ -4,11 +4,20 @@ }
-
@Model.Location.Region, @Model.Location.Name
+
@Model.Location.Name, @Model.Location.Region
Last updated on @Model.Current.LastUpdated
-
@Model.Current.Temperature°F
@Model.Current.ConditionName
+
@Model.Current.Temperature°F
+ +@foreach (var forecast in Model.Forecast) +{ +
+
@forecast.Summary.ConditionName
+
@forecast.Summary.HighTemp
+
@forecast.Summary.LowTemp
+
+} \ No newline at end of file diff --git a/WeatherDashboard/WeatherSet.cs b/WeatherDashboard/WeatherSet.cs index d036bd7..7badda1 100644 --- a/WeatherDashboard/WeatherSet.cs +++ b/WeatherDashboard/WeatherSet.cs @@ -1,8 +1,36 @@ -namespace WeatherDashboard +using Newtonsoft.Json; + +namespace WeatherDashboard { + [JsonConverter(typeof(JsonPathConverter))] public class WeatherSet { + [JsonProperty("location")] public Location Location { get; set; } + + [JsonProperty("current")] public CurrentForecast Current { get; set; } + + [JsonProperty("forecast.forecastday")] + public ICollection Forecast { get; set; } + } + + public class Forecast + { + [JsonProperty("day")] + public ForecastSummary Summary { get; set; } + } + + [JsonConverter(typeof(JsonPathConverter))] + public class ForecastSummary + { + [JsonProperty("condition.text")] + public string ConditionName { get; set; } + + [JsonProperty("maxtemp_f")] + public decimal HighTemp { get; set; } + + [JsonProperty("mintemp_f")] + public decimal LowTemp { get; set; } } } \ No newline at end of file