public static void SaveToDb(UserAuth userAuth, Match match, MatchStats matchStats) { JWT jwt; int matchId; jwt = Auth(userAuth).GetAwaiter().GetResult(); matchId = PostMatchAsync(userAuth, jwt, match).GetAwaiter().GetResult(); matchStats.match_id = matchId; PostMatchStatsAsync(userAuth, jwt, matchStats).GetAwaiter().GetResult(); }
static async Task PostMatchStatsAsync(UserAuth userAuth, JWT jwt, MatchStats matchStats) { HttpClient client = new HttpClient(); string url = "https://api.jasonfigueroa.io/matchstats"; client.DefaultRequestHeaders.Add("Authorization", $"JWT {jwt.access_token}"); string serializedMatchStats = JsonConvert.SerializeObject(matchStats); StringContent matchStatsStringContent = new StringContent(serializedMatchStats, Encoding.UTF8, "application/json"); HttpResponseMessage matchStatsResponseMessage = await client.PostAsync(url, matchStatsStringContent); }