コード例 #1
0
        public List <player> GetAllPlayers(int clubId, int teamId = 0)
        {
            var           cs         = Services.ContentService;
            List <player> AllPlayers = new List <player>();

            if (teamId == 0)
            {
                var children = cs.GetChildren(clubId);
                int fetchId  = new int();

                foreach (var child in children)
                {
                    if (child.ContentTypeId == 1127)
                    {
                        fetchId = child.Id;
                    }
                }

                var players = cs.GetChildren(fetchId);

                foreach (var player in players)
                {
                    player p = new Models.player();

                    p.id             = player.Id;
                    p.playerName     = (player.Properties["playerName"].Value != null) ? player.Properties["playerName"].Value.ToString() : null;
                    p.playerNumber   = (player.Properties["playerNumber"].Value != null) ? int.Parse(player.Properties["playerNumber"].Value.ToString()) : 0;
                    p.playerPosition = (player.Properties["playerPosition"].Value != null) ? player.Properties["playerPosition"].Value.ToString() : null;
                    p.playerAge      = (player.Properties["playerAge"].Value != null) ? player.Properties["playerAge"].Value.ToString() : null;
                    p.playerPicture  = (player.Properties["playerPicture"].Value != null) ? this.GetImg(player.Properties["playerPicture"].Value.ToString()) : null;

                    AllPlayers.Add(p);
                }
            }
            else
            {
                var team = cs.GetById(teamId);
                AllPlayers = (team.Properties["players"].Value != null) ? this.GetPlayers(team.Properties["players"].Value.ToString()) : null;
            }

            return(AllPlayers);
        }
コード例 #2
0
        private Dictionary <string, player> addPlayersToDB(HandHistory handHistory)
        {
            Dictionary <string, player> playerDict = new Dictionary <string, player>();

            foreach (Player item in handHistory.Players)
            {
                if (item.PlayerName == null)
                {
                    continue;
                }
                player dbPlayer = db.players
                                  .Where(s => s.Name == item.PlayerName)
                                  .SingleOrDefault();
                if (dbPlayer == null)
                {
                    dbPlayer = new Models.player {
                        Name = item.PlayerName
                    };
                    db.players.Add(dbPlayer);
                }
                playerDict.Add(dbPlayer.Name, dbPlayer);
            }
            return(playerDict);
        }