Esempio n. 1
0
 public string GetPlayerDatajson(int teamid)
 {
     using (NBAPlayersEntities1 context = new NBAPlayersEntities1())
     {
         var          PlayerInfo = context.Players.Where(p => p.TeamID == teamid).ToArray();
         PlayerData[] playersarr = new PlayerData[PlayerInfo.Count()];
         for (int i = 0; i < playersarr.Count(); i++)
         {
             playersarr[i] = new PlayerData {
                 name   = PlayerInfo[i].Name, playerid = PlayerInfo[i].PlayerID, position = PlayerInfo[i].Position,
                 teamid = PlayerInfo[i].TeamID
             };
         }
         ;
         return(new JavaScriptSerializer().Serialize(playersarr));
     }
 }
Esempio n. 2
0
 public List <PlayerData> GetPlayerData(string pos)
 {
     using (NBAPlayersEntities1 context = new NBAPlayersEntities1())
     {
         List <Player>     PlayerInfo = context.Players.Where(p => p.Position == pos).ToList();
         List <PlayerData> LPd        = new List <PlayerData>();
         foreach (var item in PlayerInfo)
         {
             PlayerData pd = new PlayerData
             {
                 playerid = item.PlayerID,
                 name     = item.Name,
                 position = item.Position,
                 teamid   = item.TeamID
             };
             LPd.Add(pd);
         }
         return(LPd.ToList());
     }
 }