private async Task<bool> GetItemsForMatch(FootballMatch match) { string UrlRound = DataSource.host + "round/"; string UrlTournament = DataSource.host + "tournament/"; Tournament t; Round r; Uri UriRound = new Uri(UrlRound + match.round_id.ToString() + "?access_token=" + DataSource.accessToken + "&" + Guid.NewGuid().ToString()); //StorageFile fileRound = await StorageFile.GetFileFromApplicationUriAsync(UriRound); var responseR = await httpClient.GetAsync(UriRound); //try //{ responseR.EnsureSuccessStatusCode(); //} //catch (Exception ex) //{ // return false; //} string resultR = await responseR.Content.ReadAsStringAsync(); JsonObject jsonObjectRound = JsonObject.Parse(resultR); Uri UriTrnmt = new Uri(UrlTournament + jsonObjectRound["tournament_id"].GetNumber().ToString() + "?access_token=" + DataSource.accessToken + "&" + Guid.NewGuid().ToString()); var responseT = await httpClient.GetAsync(UriTrnmt); //try //{ responseT.EnsureSuccessStatusCode(); //} //catch (Exception ex) //{ // return false; //} string resultT = await responseT.Content.ReadAsStringAsync(); JsonObject jsonObjectTournament = JsonObject.Parse(resultT); //StorageFile fileTournament = await StorageFile.GetFileFromApplicationUriAsync(UriTrnmt); //string jsonTextTournament = await FileIO.ReadTextAsync(fileTournament); //JsonObject jsonObjectTournament = JsonObject.Parse(jsonTextTournament); string impath = ""; if (jsonObjectTournament["image_path"].ValueType.Equals(JsonValueType.String)) impath = jsonObjectTournament["image_path"].GetString(); t = new Tournament((int)jsonObjectTournament["id"].GetNumber(), jsonObjectTournament["title"].GetString(), jsonObjectTournament["location"].GetString(), impath); r = new Round((int)jsonObjectRound["id"].GetNumber(), jsonObjectRound["name"].GetString(), (int)jsonObjectRound["tournament_id"].GetNumber()); await GetProtocolItemsGroup(match, t); Tournament to = await GetTournamentAsync((int)jsonObjectRound["tournament_id"].GetNumber()); Round ro = await GetRoundAsync(match.round_id); if (to == null) { r.Items.Add(match); t.RoundsList.Add(r); this.Tournaments.Add(t); } else if (ro == null) { r.Items.Add(match); to.RoundsList.Add(r); } else if (await GetItemAsync(match.id) == null) { ro.Items.Add(match); } return true; }
private async Task<bool> GetProtocolItemsGroup(FootballMatch match, Tournament t) { await GetApplicant(match, t.id); await GetMatchPlayers(match.id, match); await GetYellowCards(match.id, match); await GetRedCards(match.id, match); await GetGoals(match.id, match); return true; }