Ejemplo n.º 1
0
        //  Tested
        //  14/12/2018
        public static IEnumerable <FixtureResultParseDto> ParseFixturesDataSource(DataSourceFixture source, string nodeClassname)
        {
            var results = new List <FixtureResultParseDto>();
            var web     = new HtmlWeb();
            var htmlDoc = web.Load(source.Url);

            var htmlTables = ParseHtmlSplitTables(htmlDoc.ParsedText, nodeClassname);


            foreach (var table in htmlTables)
            {
                var htmlDocument = new HtmlDocument();
                htmlDocument.LoadHtml(table);
                //Gives you all the TR
                var trs = htmlDocument.DocumentNode.Descendants("TR").ToArray();

                var takeCount          = (trs.Length - 2);
                var trsFiltered        = trs.Skip(2).Take(takeCount);
                var trDivisionDetail   = trs.First();
                var subDivisionDetails = trDivisionDetail.InnerText.Trim();

                foreach (var tr in trsFiltered)
                {
                    // Get All the TD's
                    var tds = tr.Descendants("TD").ToArray();


                    var rslt = new FixtureResultParseDto
                    {
                        FixtureDate          = GetDate(tds[0].InnerText.Trim()),
                        FixtureHomeTeamName  = tds[1].InnerText.Trim(),
                        FixtureAwayTeamName  = tds[2].InnerText.Trim(),
                        SubDivisionParseName = subDivisionDetails
                    };

                    results.Add(rslt);
                }
            }

            return(results);
        }
Ejemplo n.º 2
0
 public async Task CreateFixtureDataSourceAsync(DataSourceFixture dataSourceFixture)
 {
     _wpbDataContext.DataSourceFixtures.Add(dataSourceFixture);
     await _wpbDataContext.SaveChangesAsync();
 }