public LadderWeek LadderWeek(int weekId) { using (var db = new LadderDbContext()) { return(db.LadderWeeks.Find(weekId)); } }
public Match GetMatchById(int id) { using (var db = new LadderDbContext()) { return(db.Matches.Find(id)); } }
public LadderWeek CurrentWeek() { using (var db = new LadderDbContext()) { return(db.LadderWeeks.Where(c => c.IsCurrent).First()); } }
public int GetPlayerStanding(int weekId, int playerId) { using (var db = new LadderDbContext()) { return((from s in db.Standings where s.LadderWeekId == weekId && s.PlayerId == playerId select s.Position).First()); } }
public List <LadderWeek> LadderWeeks() { using (var db = new LadderDbContext()) { var c = from LadderWeek s in db.LadderWeeks.Include(l => l.Standings) select s; return(c.ToList()); } }
public List <Standing> CurrentStandings() { using (var db = new LadderDbContext()) { var c = from Standing s in db.Standings.Include(l => l.Player) where s.LadderWeek.IsCurrent orderby s.Position select s; return(c.ToList()); } }
public Player Player(int playerId) { using (var db = new LadderDbContext()) { db.Configuration.LazyLoadingEnabled = false; var c = from Player s in db.Players.Include("Standings").Include("Standings.LadderWeek") where s.Id == playerId select s; return(c.First()); } }
public List <Match> CurrentMatches() { using (var db = new LadderDbContext()) { var c = from Match s in db.Matches.Include(w => w.Winner).Include(l => l.Looser) where s.LadderWeek.IsCurrent orderby s.DateOfMatch select s; return(c.ToList()); } }
public List <Match> PlayerMatches(int playerId) { using (var db = new LadderDbContext()) { var c = from Match s in db.Matches.Include(w => w.Winner).Include(l => l.Looser).Include(t => t.LadderWeek) where s.LooserId == playerId || s.WinnerId == playerId orderby s.DateOfMatch select s; return(c.ToList()); } }
public IEnumerable <Match> GetAllMatches(params Expression <Func <Match, object> >[] includeProperties) { using (var db = new LadderDbContext()) { IQueryable <Match> query = db.Matches; foreach (var includeProperty in includeProperties) { query = query.Include(includeProperty); } return(query.ToList()); } }