Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Play Page #78

Merged
merged 2 commits into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ServerCore/Pages/Teams/Play.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
@Html.DisplayFor(modelItem => item.Puzzle.OrderInGroup)
</td>
<td>
@Html.DisplayFor(modelItem => item.Puzzle.PuzzleFile == null ? null : item.Puzzle.PuzzleFile.ShortName)
@Html.DisplayFor(modelItem => item.Puzzle.PuzzleFile.ShortName)
</td>
@if (showAnswers) {
<td>
@Html.DisplayFor(modelItem => item.Puzzle.AnswerFile == null ? null : item.Puzzle.AnswerFile.ShortName)
@Html.DisplayFor(modelItem => item.Puzzle.AnswerFile.ShortName)
</td>
}
<td>
Expand Down
5 changes: 3 additions & 2 deletions ServerCore/Pages/Teams/Play.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public async Task OnGetAsync(int id, SortOrder? sort)
var stateForTeamQ = _context.PuzzleStatePerTeam.Where(state => state.TeamID == id && state.UnlockedTime != null);

// join 'em (note: just getting all properties for max flexibility, can pick and choose columns for perf later)
var visiblePuzzlesQ = puzzlesInEventQ.Join(stateForTeamQ, (puzzle => puzzle.ID), (state => state.PuzzleID), (puzzle, state) => new PuzzleWithState(puzzle, state));
// Note: EF gotcha is that you have to join into anonymous types in order to not lose valuable stuff
var visiblePuzzlesQ = puzzlesInEventQ.Join(stateForTeamQ, (puzzle => puzzle.ID), (state => state.PuzzleID), (Puzzle, State) => new { Puzzle, State });

switch (sort ?? DefaultSort)
{
Expand All @@ -69,7 +70,7 @@ public async Task OnGetAsync(int id, SortOrder? sort)
throw new ArgumentException($"unknown sort: {sort}");
}

PuzzlesWithState = await visiblePuzzlesQ.ToListAsync();
PuzzlesWithState = (await visiblePuzzlesQ.ToListAsync()).Select(x => new PuzzleWithState(x.Puzzle, x.State)).ToList();
}

public SortOrder? SortForColumnLink(SortOrder ascendingSort, SortOrder descendingSort)
Expand Down