zhaw-dnet2/Tasks/Lab13/BlazorRankingClient/Components/Pages/Ranking.razor

47 lines
997 B
Plaintext
Raw Normal View History

@page "/ranking"
@using RankingService
@attribute [StreamRendering]
<PageTitle>Ranking</PageTitle>
<h1>Ranking</h1>
<p>This component demonstrates showing data.</p>
@if (rankings == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Time</th>
</tr>
</thead>
<tbody>
@for (int i = 0; i < rankings.Length; i++)
{
<tr>
<td>@(i + 1)</td>
<td>@rankings[i].Name</td>
<td>@rankings[i].Time</td>
</tr>
}
</tbody>
</table>
}
@code {
private RankingClient client = new RankingClient("http://localhost:5072", new HttpClient());
private Competitor[]? rankings;
protected override async Task OnInitializedAsync()
{
rankings = (await client.RankingsAsync()).ToArray();
}
}