/// <summary> /// Get TieBreaker Games for a given owner and season week /// </summary> /// <param name="uniqueId">The owner code (uniqueId) of the owner.</param> /// <param name="seasonWeekId">The season week representing the season week.</param> public IEnumerable<LoserPoolPick> GetLoserPoolPicksForWeek(string uniqueId, int seasonWeekId) { List<LoserPoolPick> loserPoolPicks = new List<LoserPoolPick>(); var seasonWeek = context.SeasonWeeks.Where(sw => sw.SeasonWeekId == seasonWeekId).First(); var owner = context.Owners.Where(o => o.UniqueId == uniqueId).First(); List<Team> teams = new List<Team>(); foreach(var lpp in context.LoserPoolPicks.Where(lpp => lpp.OwnerId == owner.OwnerId && lpp.SeasonWeekId == seasonWeek.SeasonWeekId)) { var team = new Team { TeamId = lpp.TeamId, TeamPictureUrl = (lpp.TeamId > 0 ? string.Format(TEAMPICROOT_URL, context.Teams.Where(t => t.TeamId == Convert.ToInt32(lpp.TeamId)).First().Abbreviation) : string.Empty), TeamUrl = (lpp.TeamId > 0 ? string.Format(TEAMROOT_URL, context.Teams.Where(t => t.TeamId == Convert.ToInt32(lpp.TeamId)).First().Abbreviation) : string.Empty), IsLocked = lpp.IsLocked, IsBye = lpp.IsBye }; teams.Add(team); } var loserPoolPick = new LoserPoolPick { OwnerId = owner.OwnerId, SeasonWeekId = seasonWeek.SeasonWeekId, Teams = teams }; loserPoolPicks.Add(loserPoolPick); return loserPoolPicks; }
public IEnumerable<Team> GetLoserPoolPicksLeft(string uniqueId) { List<Team> teamsLeft = new List<Team>(); var owner = context.Owners.Where(o => o.UniqueId == uniqueId).First(); foreach(var t in context.Teams.Where(t => !context.LoserPoolPicks.Where(lpp => lpp.OwnerId == owner.OwnerId && lpp.IsBye == false).Select(lpp => lpp.TeamId).Contains(t.TeamId))) { var team = new Team { TeamId = t.TeamId, TeamPictureUrl = string.Format(TEAMPICROOT_URL, t.Abbreviation), TeamUrl = string.Format(TEAMROOT_URL, t.Abbreviation), IsBye = false, IsLocked = false }; teamsLeft.Add(team); } var byesLeft = 2 - context.LoserPoolPicks.Where(lpp => lpp.IsBye == true && lpp.OwnerId == owner.OwnerId).Count(); for (int i = 1; i <= byesLeft; i++) { var byeTeam = new Team { TeamId = null, TeamPictureUrl = string.Empty, TeamUrl = string.Empty, IsBye = true, IsLocked = false }; teamsLeft.Add(byeTeam); } return teamsLeft; }