Esempio n. 1
0
 public static bool WeekExists(int year, int week)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.TeamRecords.Where(tr => tr.Year == year && tr.Week == week).FirstOrDefault() != null);
     }
 }
Esempio n. 2
0
 public static List <Team> GetAllTeams()
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.Teams.ToList());
     }
 }
Esempio n. 3
0
 public static bool YearExists(int year)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.Games.Where(g => g.Year == year).FirstOrDefault() != null);
     }
 }
Esempio n. 4
0
 public static Player GetById(int id)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.Players.Where(p => p.Id == id).FirstOrDefault());
     }
 }
Esempio n. 5
0
 public static Team GetById(int id)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.Teams.Where(t => t.Id == id).FirstOrDefault());
     }
 }
Esempio n. 6
0
 public static List <Player> GetAll()
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.Players.ToList());
     }
 }
Esempio n. 7
0
 public static Player GetByName(string name)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.Players.Where(p => p.Name == name).SingleOrDefault());
     }
 }
Esempio n. 8
0
 public static bool WeekExists(int year, int week)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.RosterEntries.Where(re => re.Year == year && re.Week == week).FirstOrDefault() != null);
     }
 }
Esempio n. 9
0
 public static void DeleteGamesInYear(int year)
 {
     using (var db = new FFStatsDbContext())
     {
         db.Games.RemoveRange(db.Games.Where(g => g.Year == year));
         db.SaveChanges();
     }
 }
Esempio n. 10
0
 public static void AddGames(List <Game> games)
 {
     using (var db = new FFStatsDbContext())
     {
         db.Games.AddRange(games);
         db.SaveChanges();
     }
 }
Esempio n. 11
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();
     }
 }
Esempio n. 12
0
 public static void Add(List <PlayoffProbability> playoffProbs)
 {
     using (var db = new FFStatsDbContext())
     {
         db.PlayoffProbabilities.AddRange(playoffProbs);
         db.SaveChanges();
     }
 }
Esempio n. 13
0
 public static void Update(SeasonInfo seasonInfo)
 {
     using (var db = new FFStatsDbContext())
     {
         db.SeasonInfo.Update(seasonInfo);
         db.SaveChanges();
     }
 }
Esempio n. 14
0
 public static void Add(TeamRecord teamRecord)
 {
     using (var db = new FFStatsDbContext())
     {
         db.TeamRecords.Add(teamRecord);
         db.SaveChanges();
     }
 }
Esempio n. 15
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();
     }
 }
Esempio n. 16
0
 public static int GetNumChampion(int teamId)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.SeasonInfo
                .Include(si => si.Champion)
                .Count(si => si.Champion.Id == teamId));
     }
 }
Esempio n. 17
0
 public static List <Player> GetAll(char firstChar)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.Players
                .Where(p => p.Name.StartsWith(firstChar))
                .ToList());
     }
 }
Esempio n. 18
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();
     }
 }
Esempio n. 19
0
 public static bool WeekExists(int year, int week)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.PlayoffProbabilities
                .Where(pp => pp.Year == year && pp.Week == week)
                .FirstOrDefault() != null);
     }
 }
Esempio n. 20
0
        public static SeasonInfo Add(SeasonInfo seasonInfo)
        {
            using (var db = new FFStatsDbContext())
            {
                db.SeasonInfo.Add(seasonInfo);
                db.SaveChanges();
            }

            return(seasonInfo);
        }
Esempio n. 21
0
        public static Game AddGame(Game game)
        {
            using (var db = new FFStatsDbContext())
            {
                db.Games.Add(game);
                db.SaveChanges();
            }

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

            return(team);
        }
Esempio n. 23
0
        public static RosterEntry Add(RosterEntry entry)
        {
            using (var db = new FFStatsDbContext())
            {
                db.RosterEntries.Add(entry);
                db.SaveChanges();
            }

            return(entry);
        }
Esempio n. 24
0
        public static Player Add(Player player)
        {
            using (var db = new FFStatsDbContext())
            {
                db.Players.Add(player);
                db.SaveChanges();
            }

            return(player);
        }
Esempio n. 25
0
 // tuple: year, num teams, num weeks on roster, num weeks started
 // TODO: create class to represent this
 public static List <Tuple <int, int, int, int> > GetNumWeeksOnRosterGroupedByYear(int playerId)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.RosterEntries
                .Where(re => re.PlayerId == playerId)
                .GroupBy(re => re.Year)
                .Select(g => Tuple.Create(g.Key, g.Select(re => re.TeamId).Distinct().Count(), g.Count(), g.Count(re => re.Position <= Position.FLX)))
                .ToList());
     }
 }
Esempio n. 26
0
 public static List <Game> GetGamesByWeek(int year, int week)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.Games
                .Where(g => g.Year == year && g.Week == week)
                .Include(g => g.GameScores)
                .ThenInclude(gs => gs.Team)
                .ToList());
     }
 }
Esempio n. 27
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();
     }
 }
Esempio n. 28
0
 public static List <Team> GetTeamsInYear(int year)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.GameScores
                .Where(gs => gs.Year == year)
                .Select(gs => gs.Team)
                .Distinct()
                .ToList());
     }
 }
Esempio n. 29
0
 public static List <RosterEntry> GetByTeamAndWeek(int teamId, int year, int week)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.RosterEntries
                .Where(re => re.Year == year && re.Week == week && re.TeamId == teamId)
                .Include(re => re.Player)
                .OrderBy(re => re.Position)
                .ToList());
     }
 }
Esempio n. 30
0
 public static List <Tuple <int, double?> > GetTotalPointsPerTeam(int year, int week)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.RosterEntries
                .Where(re => re.Year == year && re.Week == week && re.Position <= Position.FLX)
                .GroupBy(re => re.TeamId)
                .Select(g => Tuple.Create(g.Key, g.Sum(re => re.Points)))
                .ToList());
     }
 }