@page "/ranking"
@using RankingApp.Data.Models;
@using RankingApp.Data.Services;
@inject RankingService _rankingService;
Ranking
@if (_gameResults == null)
{
Loading...
}
else
{
User name |
Score |
Date |
@foreach (var gameResult in _gameResults)
{
@gameResult.UserName |
@gameResult.Score |
@gameResult.Date.ToShortDateString() |
}
@if (_showPopup)
{
}
}
You have no authorization to access.
@code {
List _gameResults;
bool _showPopup;
GameResult _gameResult;
protected async override Task OnInitializedAsync()
{
await base.OnInitializedAsync();
_gameResults = await _rankingService.GetGameResultsAsync();
}
void AddGameResult()
{
_showPopup = true;
_gameResult = new GameResult() { Id = 0 };
}
void ClosePopup()
{
_showPopup = false;
}
async Task SaveGameResult()
{
if (_gameResult.Id == 0)
{
_gameResult.Date = DateTime.Now;
var result = _rankingService.AddGameResult(_gameResult);
}
else
{
}
_gameResults = await _rankingService.GetGameResultsAsync();
ClosePopup();
}
}