public async Task <List <CompetitorData> > BuildGamingListByDateForCompetition(CompetitionData comp, DateTime date)
        {
            List <CompetitorData> competitors = null;

            try
            {
                var param = string.Format(API_ExtraParam,
                                          HttpUtility.UrlEncode(string.Format(DateTime.UtcNow.Date > date.Date ? MatchesByDate_Past_CallbackParam : MatchesByDate_CallbackParam, date.ToString(MatchesDateFormat))),
                                          MatchesByDate_Action,
                                          HttpUtility.UrlEncode(string.Format(MatchesByDate_Param, comp.ID)));

                var url = string.Format(ApiFormat, BASE_API_URL, MatchesByDate_Block, param);

                var fetchResult = await _dataFetcher.FetchDom(url, true);

                competitors = fetchResult != null?ParseGameList(fetchResult.HtmlDocument, date) : new List <CompetitorData>();

                foreach (var competitor in competitors)
                {
                    competitor.CompetitionData          = new CompetitionData(comp);
                    competitor.NextScan.CompetitionData = comp;
                }
            }
            catch (Exception exception)
            {
            }

            return(competitors);
        }
Exemple #2
0
        public async Task <Dictionary <int, string> > GetClubCountries()
        {
            var fetchResult = await _dataFetcher.FetchDom(URL_CLUBS);

            var allCountries = new Dictionary <int, string>();

            var countryList = fetchResult.HtmlDocument.DocumentNode.SelectNodes("//li[contains(@class,'expandable')]/.");

            foreach (var country in countryList)
            {
                try
                {
                    var areaId = country.GetAttributeValue("data-area_id", "");
                    if (!string.IsNullOrWhiteSpace(areaId))
                    {
                        var countryId   = ParseFunctions.ParsePositiveNumber(areaId);
                        var countryName = HttpUtility.HtmlDecode(country.InnerText).Trim();
                        if (!allCountries.ContainsKey(countryId) && (countryName.ToLower() == "spain" || countryName.ToLower() == "england" ||
                                                                     countryName.ToLower() == "europe"))
                        {
                            allCountries.Add(countryId, countryName);
                        }
                    }
                }
                catch (Exception exception)
                {
                }
            }

            return(allCountries);
        }