added some forecast data

This commit is contained in:
Ryan Peters 2023-02-23 10:44:52 -05:00
parent ae5eba7fde
commit d6d13a329c
3 changed files with 41 additions and 4 deletions

View File

@ -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());

View File

@ -4,11 +4,20 @@
}
<div class="location">
<div>@Model.Location.Region, @Model.Location.Name</div>
<div>@Model.Location.Name, @Model.Location.Region</div>
<small>Last updated on @Model.Current.LastUpdated</small>
</div>
<div class="current-conditions">
<div class="current-temperature">@Model.Current.Temperature<span class="degrees">&#176;F</span></div>
<div class="current-condition-name">@Model.Current.ConditionName</div>
<div class="current-temperature">@Model.Current.Temperature<span class="degrees">&#176;F</span></div>
</div>
@foreach (var forecast in Model.Forecast)
{
<div class="row">
<div class="col col-6">@forecast.Summary.ConditionName</div>
<div class="col col-3">@forecast.Summary.HighTemp</div>
<div class="col col-3">@forecast.Summary.LowTemp</div>
</div>
}

View File

@ -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> 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; }
}
}