Exemplo n.º 1
0
 public static void DeleteTeamRecordsInWeek(int year, int week)
 {
     using (var db = new FFStatsDbContext())
     {
         db.TeamRecords.RemoveRange(db.TeamRecords.Where(tr => tr.Year == year && tr.Week == week));
         db.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public static void Update(SeasonInfo seasonInfo)
 {
     using (var db = new FFStatsDbContext())
     {
         db.SeasonInfo.Update(seasonInfo);
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public static void Add(TeamRecord teamRecord)
 {
     using (var db = new FFStatsDbContext())
     {
         db.TeamRecords.Add(teamRecord);
         db.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public static void Add(List <PlayoffProbability> playoffProbs)
 {
     using (var db = new FFStatsDbContext())
     {
         db.PlayoffProbabilities.AddRange(playoffProbs);
         db.SaveChanges();
     }
 }
Exemplo n.º 5
0
 public static void DeleteGamesInYear(int year)
 {
     using (var db = new FFStatsDbContext())
     {
         db.Games.RemoveRange(db.Games.Where(g => g.Year == year));
         db.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public static void DeleteRostersInWeek(int year, int week)
 {
     using (var db = new FFStatsDbContext())
     {
         db.RemoveRange(db.RosterEntries.Where(re => re.Year == year && re.Week == week));
         db.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public static void AddGames(List <Game> games)
 {
     using (var db = new FFStatsDbContext())
     {
         db.Games.AddRange(games);
         db.SaveChanges();
     }
 }
Exemplo n.º 8
0
 public static void DeleteWeek(int year, int week)
 {
     using (var db = new FFStatsDbContext())
     {
         db.PlayoffProbabilities.RemoveRange(
             db.PlayoffProbabilities.Where(pp => pp.Year == year && pp.Week == week));
         db.SaveChanges();
     }
 }
Exemplo n.º 9
0
        public static SeasonInfo Add(SeasonInfo seasonInfo)
        {
            using (var db = new FFStatsDbContext())
            {
                db.SeasonInfo.Add(seasonInfo);
                db.SaveChanges();
            }

            return(seasonInfo);
        }
Exemplo n.º 10
0
        public static RosterEntry Add(RosterEntry entry)
        {
            using (var db = new FFStatsDbContext())
            {
                db.RosterEntries.Add(entry);
                db.SaveChanges();
            }

            return(entry);
        }
Exemplo n.º 11
0
        public static Game AddGame(Game game)
        {
            using (var db = new FFStatsDbContext())
            {
                db.Games.Add(game);
                db.SaveChanges();
            }

            return(game);
        }
Exemplo n.º 12
0
        public static Team Add(Team team)
        {
            using (var db = new FFStatsDbContext())
            {
                db.Teams.Add(team);
                db.SaveChanges();
            }

            return(team);
        }
Exemplo n.º 13
0
        public static Player Add(Player player)
        {
            using (var db = new FFStatsDbContext())
            {
                db.Players.Add(player);
                db.SaveChanges();
            }

            return(player);
        }
Exemplo n.º 14
0
 public static void UpdatePoints(int year, int week, int teamId, double?points)
 {
     using (var db = new FFStatsDbContext())
     {
         db.GameScores
         .Where(gs => gs.Year == year && gs.Week == week && gs.TeamId == teamId)
         .First()
         .Points = points;
         db.SaveChanges();
     }
 }
Exemplo n.º 15
0
        public static void Add(List <TeamRecord> teamRecords)
        {
            using (var db = new FFStatsDbContext())
            {
                db.TeamRecords.AddRange(teamRecords);

                // the call to AddRange above will set Team in TeamRecord as added,
                // but since they already exist in the database we need to detach them
                foreach (var teamRecord in teamRecords)
                {
                    if (teamRecord.Team != null)
                    {
                        db.Entry(teamRecord.Team).State = EntityState.Detached;
                    }
                }

                db.SaveChanges();
            }
        }
Exemplo n.º 16
0
        public static void Add(List <RosterEntry> entries)
        {
            using (var db = new FFStatsDbContext())
            {
                db.RosterEntries.AddRange(entries);

                // the call to AddRange above will set Player in RosterEntry as added,
                // but since they already exist in the database we need to detach them
                foreach (var entry in entries)
                {
                    if (entry.Player != null)
                    {
                        db.Entry(entry.Player).State = EntityState.Detached;
                    }
                }

                db.SaveChanges();
            }
        }