public async void GetAllGames() { AmostiService amostiService = new AmostiService(); GameNames.Clear(); var gameResults = await amostiService.GetGames(); foreach (var item in gameResults) { if (item.GameName != null && item.GameName != "null") { GameNames.Add(item); } } }
private async void GetGameScores(string gamename) { AmostiService amostiService = new AmostiService(); GameHighScores.Clear(); var scores = await amostiService.GetGameScores(gamename); RecordId = scores.First().recordId; // Finner id til verdien med høyest score, usannsynlig unødvendig siden id ble satt av apiet foreach (var score in scores) { var username = score.playerName; var points = score.score; GameHighScores.Add(new SingleGameHighScorecs() { HighScore = points, Username = username }); } }
private async void SubmitBtn_OnClicked(object sender, EventArgs e) { if (Score.Text != null) { var scoreConvert = Int32.Parse(Score.Text); RecordId += 1; var amosti = new AmostiService(); var newScore = new GameScoreBoard() { gameName = GameName, playerName = "Batman", recordId = RecordId, score = scoreConvert }; await amosti.AddHighScore(newScore, true); Navigation.RemovePage(this); } else { await DisplayAlert("Score not filled", "Seems like you forgot to add a score", "Try Again"); } }