Ejemplo n.º 1
0
        public Player GetPlayerProfile(string playerId)
        {
            var htmlDoc  = TennisNzSite.GetTennisNZPage($"ResultsHistoryList.asp?pID={playerId}&gtID=2&CP=GradingList");
            var fullName = htmlDoc.DocumentNode.SelectSingleNode("//td[@class='subhdg']").InnerText;

            return(new Player {
                Name = fullName
            });
        }
Ejemplo n.º 2
0
        public List <Player> GetAllPlayers(bool fromCache = true)
        {
            List <Player> tennisNzPlayers = null;

            if (fromCache)
            {
                tennisNzPlayers = FileIO.Read(_cachePlayersFile)?.ToObject <List <Models.Player> >();
            }

            if (tennisNzPlayers != null)
            {
                return(tennisNzPlayers);
            }


            var players  = new List <Player>();
            var url      = $"GradingList.asp";
            var postData = "fPlayerSurname=" +
                           "&fSex=M" +
                           "&fGradingType=2" +
                           "&fGradeCd=" +
                           "&frd=" +
                           "&fClub=" +
                           "&fAgegroup=" +
                           "&fAgegroupDate=30+Nov+2018" +
                           "&MyStuff=TopDog+Top+Dog+Yardstick" +
                           "&MySubmitAction=Search" +
                           "&CallingPage=GradingList.asp" +
                           "&GradingListIsSubmitted=Yes";



            //get first list of players
            var firstPage = TennisNzSite.GetTennisNZPage(url, postData, "POST");

            players.AddRange(ExtractPlayer(firstPage));

            //get all other pages
            var nextPagePlayers = ExtractPlayer2(TennisNzSite.GetTennisNZPage(url, postData.Replace("Search", "Next"), "POST"));

            while (nextPagePlayers.Count > 0)
            {
                players.AddRange(nextPagePlayers);
                nextPagePlayers = ExtractPlayer2(TennisNzSite.GetTennisNZPage(url, postData.Replace("Search", "Next"), "POST"));
            }

            FileIO.Save(_cachePlayersFile, players.ToJson());

            return(players);
        }
Ejemplo n.º 3
0
        public List <Match> GetPlayerResults(string playerId)
        {
            var htmlDoc     = TennisNzSite.GetTennisNZPage($"ResultsHistoryList.asp?pID={playerId}&gtID=2&CP=GradingList");
            var resultsRows = htmlDoc.DocumentNode.SelectNodes("//form/table[1]/tr[3]/td[1]/div/table/colgroup[1]/colgroup[1]/colgroup[1]/colgroup[1]/colgroup[1]/colgroup[1]/colgroup[1]/colgroup[1]/tr");

            var matches = new List <Match>();

            foreach (HtmlNode row in resultsRows)
            {
                var matchDate = row.SelectSingleNode("td[1]").InnerText.ToDateTime();
                if (matchDate != null)
                {
                    var playerTwoId = row.SelectSingleNode("td[5]").InnerText;
                    matches.Add(new Match
                    {
                        Date        = matchDate.Value,
                        PlayerOneId = playerId,
                        PlayerTwoId = playerTwoId
                    });
                }
            }

            return(matches);
        }