// GET: Team public ActionResult Index(int id) { var model = new TeamViewModel(); using (ApplicationDbContext context = new ApplicationDbContext()) { var team = context.Teams.Find(id); model.TeamId = id; model.RosterPlayersToAdd = new SelectList(team.RosterPlayers.Select(p => p.Player).ToList(), "Id", "LexicalName").ToList(); model.RosterPlayers = team.RosterPlayers.Select(p => new PlayerInterval(p)).OrderBy(p => p, new PlayerIntervalComparer()).ToList(); model.AvailablePlayers = AvailablePlayers(team.PoolId); model.Intervals = new SelectList(context.IntervalsByPoolSeason(team.PoolId, 2), "Id", "Name").ToList(); //model.PlayerIntervals = GetPlayerIntervals(id, context.IntervalsByPoolSeason(team.PoolId, 1).First().Id).ToList(); model.SelectedIntervalId = GetCurrentInterval(); model.CanSubmit = GetCanSubmit(model.TeamId, model.SelectedIntervalId); model.SelectedStartTime = GetIntervalStartTime(model.SelectedIntervalId).ToString(); } return View(model); }