Exemplo n.º 1
0
        public static void SavePlayerList(PlayerListModel list)
        {
            using (FFBcontext context = new FFBcontext())
            {

                PlayerLists PlayerList = new PlayerLists();
                PlayerList.ScheduleTypeId = list.Id;
                PlayerList.Week = list.Week;
                PlayerList.Year = list.Year;
                context.PlayerLists.Add(PlayerList);

                StreamReader csvreader = new StreamReader(list.File.InputStream);

                while (!csvreader.EndOfStream)
                {
                    if (!string.IsNullOrEmpty(csvreader.ReadLine()))
                    {
                        var result = csvreader.ReadLine().Split(',');
                        Players player = new Players();
                        player.Position = result[0].Replace(@"""", String.Empty);
                        player.Name = result[1].Replace(@"""", String.Empty);
                        player.Salary = Convert.ToInt32(result[2]);
                        player.GameInfo = result[3].Replace(@"""", String.Empty);
                        player.AvgPointsPerGame = Convert.ToDecimal(result[4]);
                        player.teamAbbrev = result[5].Replace(@"""", String.Empty);
                        player.PlayerListId = PlayerList.ScheduleTypeId;
                        context.Players.Add(player);
                    }
                }
                context.SaveChanges();
            }
        }
Exemplo n.º 2
0
 public static List<ScheduleTypeModel> GetScheduleTypes()
 {
     using (FFBcontext context = new FFBcontext())
     {
         return (from st in context.Schedule_Types
                 select new ScheduleTypeModel {
                     Id = st.Id,
                     Name = st.Name
                 }).ToList();
     }
 }
Exemplo n.º 3
0
 public static List<PlayerModel> GetAllPlayers()
 {
     using (FFBcontext context = new FFBcontext())
     {
         return (from p in context.Players
                 select new PlayerModel {
                     Id = p.Id,
                     AvgPointsPerGame = p.AvgPointsPerGame,
                     GameInfo = p.GameInfo,
                     Name = p.Name,
                     Position = p.Position,
                     Salary = p.Salary,
                     teamAbbrev = p.teamAbbrev
                 }).ToList();
     }
 }