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

Show Empty Swag #479

Merged
merged 2 commits into from
May 30, 2019
Merged
Changes from 1 commit
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
25 changes: 13 additions & 12 deletions ServerCore/Pages/Swag/Report.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ public class SwagView

public async Task<IActionResult> OnGetAsync(int? puzzleId)
{
SwagViews = await (from s in _context.Swag
join t in _context.TeamMembers on s.PlayerId equals t.Member.ID
where s.Event == Event && t.Team.Event == Event
orderby t.Team.Name, s.ShirtSize
select new SwagView()
{
PlayerName = t.Member.Name,
TeamName = t.Team.Name,
Lunch = s.Lunch,
LunchModifications = s.LunchModifications,
ShirtSize = s.ShirtSize
}).ToListAsync();
SwagViews = await (from t in _context.TeamMembers
join s in _context.Swag on t.Member.ID equals s.PlayerId into tmp
from swagState in tmp.DefaultIfEmpty()
where (swagState == null || swagState.Event == Event) && t.Team.Event == Event
orderby t.Team.Name, swagState.ShirtSize
select new SwagView()
{
PlayerName = t.Member.Name,
TeamName = t.Team.Name,
Lunch = swagState == null ? null : swagState.Lunch,
LunchModifications = swagState == null ? null : swagState.LunchModifications,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could optionally be shortened to LunchModifications = swagState?.LunchModifications,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope - you can't use the ?. operator here, the compiler complains. Ask me how I know :-)

ShirtSize = swagState == null ? null : swagState.ShirtSize
}).ToListAsync();
return Page();
}
}
Expand Down