public async Task <PlayerModel[]> UpdateCurrentMatch() { // get player IDs OpenDotaAPI dotaAPI = new OpenDotaAPI(); List <string> playerIDs = dotaAPI.GetPlayerIDs(); List <Task <PlayerModel> > playerModels = new List <Task <PlayerModel> >(); for (int i = 0; i < 10; i++) { playerModels.Add(GetPlayerModel(playerIDs[i])); } var s = await Task.WhenAll(playerModels); return(s); }
public async Task <PlayerModel> GetPlayerModel(string playerID) { // get player data OpenDotaAPI dotaAPI = new OpenDotaAPI(); PlayerData playerData = await dotaAPI.GetPlayerData(playerID); // if player not valid return anon player var info = ConvertToPlayerModel(playerData); if (!info.Item1) { return(info.Item2); } PlayerModel playerModel = info.Item2; // get recent matches Match[] matches = await dotaAPI.GetPlayerRecentMatches(playerID); playerModel.RecentMatchesObservable = ConvertToRecentMatches(matches); return(playerModel); }