/// <summary> /// Metoda do pobrania z API danych oraz wczytywanie ich do widoku. /// </summary> /// <param name="download">Obiekt implementujący IDownloadTeam, musi posiadać właściwość TeamsDTO</param> /// <param name="listView">Widok listy</param> public async void DownloadData(IDownloadTeam download, ListView listView) { await download.HttpCall(); Results = download.results; List <CustomTeam> list = new List <CustomTeam>(); if (Results != null) { int lp = 1; foreach (var result in Results.Teams) { CustomTeam custom = new CustomTeam() { Lp = lp.ToString() + ".", Name = result.Name }; list.Add(custom); lp++; } listView.ItemsSource = list; listView.ItemTemplate = new DataTemplate(typeof(TeamsItemView)); } }
public async System.Threading.Tasks.Task HttpCall() { results = new TeamsDTO(); var result = new TeamDTO() { Name = "druzyna" }; results.Teams.Add(result); }
public async System.Threading.Tasks.Task HttpCall() { try { HttpClient client = new HttpClient(); HttpResponseMessage response = await client.GetAsync(new Uri(Configuration.API_COMPETITIONS + "/" + (Application.Current as App).CompetitionId) + "/teams"); string responseJson = await response.Content.ReadAsStringAsync(); results = JsonConvert.DeserializeObject <TeamsDTO>(responseJson); } catch (Exception ex) { } }