public static async void SaveStats() { // TO-DO: Save the stats into stats table var dialog = new MessageDialog("Good Work!\nScore: " + score + "\nAvarage time: " + avg_time + " sec \nLongest Strike:" + strike); var res = dialog.ShowAsync(); Client_trivia_Aluma_Gelbard.RemoteDatabaseService.TriviaServiceClient proxy = new Client_trivia_Aluma_Gelbard.RemoteDatabaseService.TriviaServiceClient(); RemoteDatabaseService.Score prev_score = await proxy.GetUserScoreAsync(Classes.UserManager.myUser.user_ID); Score user_score = new Score(); if (prev_score == null) { user_score.user_id = Classes.UserManager.myUser.user_ID; user_score.score = score; user_score.late_score = score; user_score.highest_score = score; user_score.longest_strike = strike; user_score.fastest_time = (float)best_time; await proxy.SaveScoreAsync(user_score); } else { user_score.user_id = Classes.UserManager.myUser.user_ID; user_score.late_score = score; user_score.score = score + prev_score.score; user_score.highest_score = prev_score.highest_score > score ? prev_score.highest_score : score; user_score.longest_strike = prev_score.longest_strike > strike ? prev_score.longest_strike : strike; user_score.fastest_time = prev_score.fastest_time > (float)best_time ? prev_score.fastest_time : (float)best_time; await proxy.UpdateScoreAsync(user_score); } }
private async void Page_Loaded(object sender, RoutedEventArgs e) { Client_trivia_Aluma_Gelbard.RemoteDatabaseService.TriviaServiceClient proxy = new Client_trivia_Aluma_Gelbard.RemoteDatabaseService.TriviaServiceClient(); Score result = await proxy.GetUserScoreAsync(Classes.UserManager.myUser.user_ID); this.score_tb.Text = "Total Score: " + (result.score).ToString(); this.highscore_tb.Text = "Highest Score: " + (result.highest_score).ToString(); this.lategame_tb.Text = "Last Game Score: " + (result.late_score).ToString(); this.fastest_tb.Text = "Fastest Time: " + (result.fastest_time).ToString(); this.strike_tb.Text = "Longest Strike: " + (result.longest_strike).ToString(); }