WeatherDashboard/WeatherDashboard.Web/Views/Home/Index.cshtml

63 lines
2.0 KiB
Plaintext
Raw Normal View History

2023-02-10 03:33:02 +00:00
@model WeatherSet
@{
2023-03-20 14:15:24 +00:00
ViewData["Title"] = $"{Model.Location.Name}, {Model.Location.Region} Weather";
2023-03-20 02:06:57 +00:00
var updateAge = (DateTime.Now - Model.Current.LastUpdated.Value).Minutes;
2023-02-09 02:30:14 +00:00
}
2023-02-16 15:06:43 +00:00
<div class="location">
2023-03-20 02:06:57 +00:00
<small>Last updated @updateAge minutes ago</small>
2023-02-10 03:33:02 +00:00
</div>
2023-03-20 14:15:24 +00:00
<div class="row current-conditions">
<div class="col current-temperature">
@Model.Current.Temperature<span class="degrees">&#176;F</span>
</div>
<div class="col current-details">
<div>@Model.Current.ConditionName</div>
<div>Feels Like @Model.Current.FeelsLike</div>
<div>Humidity @Model.Current.Humidity</div>
<div>Winds @Model.Current.WindDirection / @Model.Current.WindSpeed</div>
</div>
2023-02-09 02:30:14 +00:00
</div>
2023-02-23 15:44:52 +00:00
2023-03-20 14:15:24 +00:00
<div class="forecast-details">
2023-03-18 15:16:24 +00:00
@foreach (var forecast in Model.Forecast)
{
2023-03-18 17:30:55 +00:00
var displayHours = new Dictionary<int, string>
2023-03-20 14:15:24 +00:00
{
[7] = "Morning",
2023-03-19 03:03:27 +00:00
[14] = "Afternoon",
[19] = "Evening",
[23] = "Night"
2023-03-18 17:30:55 +00:00
};
2023-03-18 15:33:19 +00:00
var hourForecasts = forecast.HourForecasts
.Where(f => f.Time > DateTime.Now)
2023-03-20 14:15:24 +00:00
.Join(displayHours, f => f.Time.Value.Hour, d => d.Key, (f, d) => new
2023-03-18 17:30:55 +00:00
{
TimeOfDay = d.Value,
Forecast = f
})
2023-03-18 15:33:19 +00:00
.ToList();
2023-03-20 14:15:24 +00:00
<div class="row day-name">
<div class="col">@forecast.Date.FriendlyDate()</div>
</div>
2023-03-18 15:16:24 +00:00
<div class="row day-summary">
2023-03-20 14:15:24 +00:00
<div class="col col-6">@forecast.Summary.ConditionName </div>
2023-03-18 15:16:24 +00:00
<div class="col col-6">@forecast.Summary.HighTemp / @forecast.Summary.LowTemp</div>
</div>
2023-03-20 14:15:24 +00:00
2023-03-18 15:33:19 +00:00
@foreach (var hourForecast in hourForecasts)
2023-03-18 15:16:24 +00:00
{
<div class="row day-detail">
2023-04-04 01:02:13 +00:00
<div class="col">@hourForecast.TimeOfDay <span class="detail-time">@hourForecast.Forecast.Time.Value.ToShortTimeString()</span></div>
2023-03-18 17:30:55 +00:00
<div class="col">@hourForecast.Forecast.ConditionName / @hourForecast.Forecast.Temperature</div>
2023-03-18 15:16:24 +00:00
</div>
}
}
</div>