/// <summary>
        /// Metoda do pobrania z API danych oraz wczytywanie ich do widoku.
        /// </summary>
        /// <param name="download">Obiekt implementujący IDownloadFixture, musi posiadać właściwość FixturesDTO</param>
        /// <param name="listView">Widok listy</param>
        public async void DownloadData(IDownloadFixture download, ListView listView)
        {
            await download.HttpCall();

            Results = download.results;

            List <CustomFixture> list = new List <CustomFixture>();

            if (Results != null)
            {
                foreach (var result in Results.Fixtures)
                {
                    CustomFixture custom = new CustomFixture()
                    {
                        Date          = result.Date.ToString("HH:mm dd.MM.yyyy") + " r.",
                        AwayTeam      = result.AwayTeamName,
                        HomeTeam      = result.HomeTeamName,
                        AwayTeamGoals = result.Result.GoalsAwayTeam.ToString(),
                        HomeTeamGoals = result.Result.GoalsHomeTeam.ToString()
                    };
                    list.Add(custom);
                }
            }

            listView.ItemsSource  = list;
            listView.ItemTemplate = new DataTemplate(typeof(FixturesItemView));
        }
        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) + "/fixtures");

                string responseJson = await response.Content.ReadAsStringAsync();

                results = JsonConvert.DeserializeObject <FixturesDTO>(responseJson);
            }
            catch (Exception ex)
            { }
        }
Exemple #3
0
        public async System.Threading.Tasks.Task HttpCall()
        {
            results = new FixturesDTO();
            var result = new FixtureResultDTO()
            {
                GoalsAwayTeam = 2,
                GoalsHomeTeam = 2
            };
            var fixture = new FixtureDTO()
            {
                AwayTeamName = "druzyna przeciwna",
                HomeTeamName = "druzyna gospodarzy",
                //Date = System.DateTime.Parse("")
                Result = result,
                Status = "active"
            };

            results.Fixtures = new List <FixtureDTO>();
            results.Fixtures.Add(fixture);
        }