Exemplo 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);
     }
 }
Exemplo n.º 2
0
 public static List <Team> GetAllTeams()
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.Teams.ToList());
     }
 }
Exemplo n.º 3
0
 public static bool YearExists(int year)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.Games.Where(g => g.Year == year).FirstOrDefault() != null);
     }
 }
Exemplo n.º 4
0
 public static Player GetById(int id)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.Players.Where(p => p.Id == id).FirstOrDefault());
     }
 }
Exemplo n.º 5
0
 public static Team GetById(int id)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.Teams.Where(t => t.Id == id).FirstOrDefault());
     }
 }
Exemplo n.º 6
0
 public static List <Player> GetAll()
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.Players.ToList());
     }
 }
Exemplo n.º 7
0
 public static Player GetByName(string name)
 {
     using (var db = new FFStatsDbContext())
     {
         return(db.Players.Where(p => p.Name == name).SingleOrDefault());
     }
 }
Exemplo 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);
     }
 }
Exemplo 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();
     }
 }
Exemplo n.º 10
0
 public static void AddGames(List <Game> games)
 {
     using (var db = new FFStatsDbContext())
     {
         db.Games.AddRange(games);
         db.SaveChanges();
     }
 }
Exemplo 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();
     }
 }
Exemplo n.º 12
0
 public static void Add(List <PlayoffProbability> playoffProbs)
 {
     using (var db = new FFStatsDbContext())
     {
         db.PlayoffProbabilities.AddRange(playoffProbs);
         db.SaveChanges();
     }
 }
Exemplo n.º 13
0
 public static void Update(SeasonInfo seasonInfo)
 {
     using (var db = new FFStatsDbContext())
     {
         db.SeasonInfo.Update(seasonInfo);
         db.SaveChanges();
     }
 }
Exemplo n.º 14
0
 public static void Add(TeamRecord teamRecord)
 {
     using (var db = new FFStatsDbContext())
     {
         db.TeamRecords.Add(teamRecord);
         db.SaveChanges();
     }
 }
Exemplo 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();
     }
 }
Exemplo 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));
     }
 }
Exemplo 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());
     }
 }
Exemplo 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();
     }
 }
Exemplo 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);
     }
 }
Exemplo n.º 20
0
        public static SeasonInfo Add(SeasonInfo seasonInfo)
        {
            using (var db = new FFStatsDbContext())
            {
                db.SeasonInfo.Add(seasonInfo);
                db.SaveChanges();
            }

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

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

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

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

            return(player);
        }
Exemplo 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());
     }
 }
Exemplo 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());
     }
 }
Exemplo 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();
     }
 }
Exemplo 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());
     }
 }
Exemplo 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());
     }
 }
Exemplo 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());
     }
 }