Skip to content

Commit

Permalink
Add day averages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Del Rincón López committed Sep 27, 2023
1 parent 132f6ef commit f68da84
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions BlazorApp1/Client/Pages/FetchData.razor
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,29 @@ else
<InputNumber @bind-Value="forecastToAdd!.TemperatureC"></InputNumber>
<button type="submit">Submit</button>
</EditForm>

<table class="table">
Day Averages
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecastGroup in forecasts.GroupBy(x => DateOnly.FromDateTime(x.Date)))
{
<tr>
<td>@forecastGroup.Key.ToShortDateString()</td>
<td>@forecastGroup.Average(x => x.TemperatureC)</td>
<td>@forecastGroup.Average(x => x.TemperatureF)</td>
<td>@string.Join(", ", @forecastGroup.Select(x => x.Summary).Distinct())</td>
</tr>
}
</tbody>
</table>
}

@code {
Expand Down

0 comments on commit f68da84

Please sign in to comment.