@page "/ranking" @using RankingApp.Data.Models; @using RankingApp.Data.Services; @inject RankingService _rankingService;

Ranking

@if (_gameResults == null) {

Loading...

} else { @foreach (var gameResult in _gameResults) { }
User name Score Date Update Delete
@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 }; } async Task UpdateGameResult(GameResult gameResult) { _gameResult = gameResult; _showPopup = true; } async Task DeleteGameResult(GameResult gameResult) { var result = _rankingService.DeleteGameResult(gameResult); _gameResults = await _rankingService.GetGameResultsAsync(); } void ClosePopup() { _showPopup = false; } async Task SaveGameResult() { ClosePopup(); if (_gameResult.Id == 0) { _gameResult.Date = DateTime.Now; var result = _rankingService.AddGameResult(_gameResult); } else { var result = _rankingService.UpdateGameResult(_gameResult); } _gameResults = await _rankingService.GetGameResultsAsync(); } }