public List <Player> GetPlayersFromRoster(HtmlDocument rosterPage, Team team)
        {
            List <Player> players = new List <Player>();
            HtmlNode      table   = FindRosterTable(rosterPage.DocumentNode);

            foreach (HtmlNode row in table.Descendants("tr").Skip(2))
            {
                IEnumerable <HtmlNode> cells = row.Descendants("td");
                string name = cells.ElementAt(1).Descendants("a").First().InnerText.Trim();

                PlayerBio bio = new PlayerBio(
                    GetHeight(cells.ElementAt(3).InnerText),
                    GetWeight(cells.ElementAt(4).InnerText),
                    GetYearsPro(cells.ElementAt(7).InnerText),
                    GetBirthDate(cells.ElementAt(5).InnerText),
                    Notations.RUS
                    );

                PlayerRoster roster = new PlayerRoster(
                    GetPos(cells.ElementAt(2).InnerText),
                    GetNumber(cells.ElementAt(0).InnerText)
                    );

                Player player = new Player(name, bio, roster, team);
                player.College = new College(cells.ElementAt(6).InnerText.Replace("&nbsp", string.Empty).
                                             Replace(";", string.Empty).Trim());
                player.Href = cells.ElementAt(1).Descendants("a").First().GetAttributeValue("href", "#");
                players.Add(player);
            }

            return(players);
        }
Beispiel #2
0
 public Player(string name, PlayerBio bio, PlayerRoster roster, Team team)
 {
     this.name   = name;
     this.bio    = bio;
     this.roster = roster;
     this.team   = team;
 }
Beispiel #3
0
        public virtual ActionResult SetBioDelete(PlayerBio input)
        {
            var myMembershipId = User.Identity.GetUserId();

            SettingsProcedures.DeletePlayerBio(myMembershipId);

            TempData["Result"] = "Your bio has been deleted.";
            return(RedirectToAction(MVC.PvP.Play()));
        }
Beispiel #4
0
 public SetBioViewModel(PlayerBio playerBio)
 {
     Id = playerBio.Id;
     OwnerMembershipId = playerBio.OwnerMembershipId;
     Text             = playerBio.Text;
     WebsiteURL       = playerBio.WebsiteURL;
     PublicVisibility = playerBio.PublicVisibility;
     Tags             = playerBio.Tags;
     Timestamp        = playerBio.Timestamp;
 }
Beispiel #5
0
 public void SavePlayerBio(PlayerBio PlayerBio)
 {
     if (PlayerBio.Id == 0)
     {
         context.PlayerBios.Add(PlayerBio);
     }
     else
     {
         var editMe = context.PlayerBios.Find(PlayerBio.Id);
         if (editMe != null)
         {
             // dbEntry.Name = PlayerBio.Name;
             // dbEntry.Message = PlayerBio.Message;
             // dbEntry.TimeStamp = PlayerBio.TimeStamp;
         }
     }
     context.SaveChanges();
 }
        public static void SavePlayerBio(SetBioViewModel bio, string membershipId)
        {
            IPlayerBioRepository playerBioRepo = new EFPlayerBioRepository();
            var playerBio = playerBioRepo.PlayerBios.FirstOrDefault(p => p.OwnerMembershipId == membershipId);

            if (playerBio == null)
            {
                playerBio = new PlayerBio
                {
                    OwnerMembershipId = membershipId,
                };
            }

            playerBio.Timestamp  = DateTime.UtcNow;
            playerBio.Text       = bio.Text;
            playerBio.WebsiteURL = bio.WebsiteURL;

            playerBio.Tags = bio.Tags;

            playerBioRepo.SavePlayerBio(playerBio);
        }
 private float GetWeight(string val)
 {
     return(PlayerBio.PoundsToKG(float.Parse(val.Trim())));
 }
 private float GetHeight(string val)
 {
     return(PlayerBio.FeetAndInchToM(val.Trim()));
 }