public async Task <IHttpActionResult> YearWizardInfo() { int currYear = this.CurrentYear; var teams = await this.Db.teamyeardatas.Include(x => x.team).Include(x => x.year).Where(x => x.year.value >= currYear - 2).ToListAsync(); var sortedUniqueTeams = teams.Where(x => x.team.validTeam).OrderByDescending(x => x.year.value).GroupBy(x => x.team.id).Select(x => x.First()).Select(x => x.team); return(Ok(new { teams = sortedUniqueTeams.Select(x => TeamResponse.From(x)) })); }
public async Task <IActionResult> GetTeam([FromRoute] Guid teamId) { try { var projection = await _teamQueryHandler.GetTeamAsync(teamId); return(Ok(TeamResponse.From(projection))); } catch { return(NotFound()); } }
public IHttpActionResult GetDataForYear(int year) { if (year < 1999 || year > DateTimeOffset.UtcNow.Year) { return(BadRequest("year not in valid range")); } this.Db.Configuration.ProxyCreationEnabled = false; // TODO: Invalid players might need to be added to this (no shows, etc) var yearDataWithPlayerForYear = this.Db.playeryeardatas.Include(p => p.player).AsNoTracking().Where(x => x.year.value == year).ToList(); var weeksForYear = this.Db.weeks.Where(w => w.year.value == year).Include(w => w.course).AsNoTracking().ToList(); var teamsForYear = this.Db.teams.AsNoTracking().Where(x => x.playeryeardatas.Any(y => y.year.value == year)).ToList(); var leaderboards = this.Db.leaderboards.AsNoTracking().ToList(); var pairings = this.Db.pairings.AsNoTracking().ToList(); var leaderBoardDataForYear = this.Db.leaderboarddatas.AsNoTracking().Where(x => x.year.value == year).ToList(); var courses = weeksForYear.Select(w => w.course).GroupBy(c => c.id).Select(g => g.First()); var teamMatchupsForYear = this.Db.teammatchups .Include(x => x.teams) .Include(x => x.matches) .Include("matches.results") .Where(x => x.week.year.value == year).ToList() .GroupBy(x => x.weekId, x => x, (key, value) => value.OrderBy(x => x.matchOrder)) .SelectMany(x => x); var dby = new DataByYear { PlayersForYear = yearDataWithPlayerForYear.Select(x => PlayerResponse.From(x)).ToList(), LeaderboardDataForYear = leaderBoardDataForYear.Select(x => LeaderBoardDataResponse.From(x)).ToList(), Leaderboards = leaderboards.Select(x => new LeaderBoardResponse(x)).ToList(), TeamsForYear = teamsForYear.Select(x => TeamResponse.From(x)).ToList(), TeamMatchups = teamMatchupsForYear.Select(x => TeamMatchupResponse.From(x)).ToList(), Courses = courses.Select(x => CourseResponse.From(x)).ToList(), Weeks = weeksForYear.Select(x => new WeekResponse(x)).ToList(), Pairings = pairings }; return(Ok(dby)); }
public ScheduleWeek(week w, GroupedPlayoffMatchup playoffMatchup, bool includeMatches = false) : base(w) { this.TeamMatchups = w.teammatchups.Select(x => includeMatches ? new TeamMatchupWithResults(x) : new ScheduleTeamMatchup(x)).OrderBy(x => x.MatchOrder).ToList(); this.Course = CourseResponse.From(w.course); this.Pairing = w.pairing.pairingText; if (playoffMatchup != null) { this.PlayoffMatchups = playoffMatchup.PlayoffMatchups.Select(y => new { team1 = TeamResponse.From(y.Team1), team2 = TeamResponse.From(y.Team2), team1Seed = y.Team1Seed, team2Seed = y.Team2Seed, playoffType = y.PlayoffType }); } }
public async Task <IActionResult> GetTeams() { var projection = await _teamQueryHandler.GetTeamsAsync(); return(Ok(TeamResponse.From(projection))); }
public ScheduleTeamMatchup(teammatchup tm) { int numOfTeams = tm.teams.Count; this.MatchOrder = tm.matchOrder; team team1 = numOfTeams > 0 ? tm.teams.First() : null; team team2 = numOfTeams > 1 ? tm.teams.Skip(1).First() : null; if (team1 != null) { this.Team1 = TeamResponse.From(team1); this.Team1Points = tm.PointsFor(team1); this.Team1Win = tm.Team1Won(); } if (team2 != null) { this.Team2 = TeamResponse.From(team2); this.Team2Points = tm.PointsFor(team2); this.Team2Win = tm.Team2Won(); } this.IsComplete = tm.IsComplete(); this.TeeTimeText = tm.TeeTimeText(); this.Id = tm.id; this.PlayoffType = tm.playoffType; if (this.IsComplete && team1 != null && team2 != null) { result team1PointsResult = tm.TopPoints(team1); //result team2PointsResult = tm.TopPoints(team2); this.TopPoints = team1PointsResult != null ? new MatchSummaryValue { Player = new PlayerWebResponse(team1PointsResult.player), FormattedValue = LeaderBoardFormat.Default.FormatValue(team1PointsResult.points), Value = (double)team1PointsResult.points } : null; result topNetScore = tm.TopNetDifference(team1); this.TopNetScore = topNetScore != null ? new MatchSummaryValue { Player = new PlayerWebResponse(topNetScore.player), FormattedValue = LeaderBoardFormat.Net.FormatValue(topNetScore.NetScoreDifference()), Value = (double)topNetScore.NetScoreDifference() } : null; //this.Team2TopPoints = team2PointsResult != null ? // new MatchSummaryValue // { // Player = new PlayerWebResponse(team2PointsResult.player), // FormattedValue = LeaderBoardFormat.Default.FormatValue(team2PointsResult.points), // Value = (double)team2PointsResult.points // } : null; } }