Refactor endpoint services to accept narrow inputs
This commit is contained in:
@@ -7,13 +7,13 @@ namespace GameList.Endpoints;
|
||||
|
||||
internal sealed class ResultsWorkflowService(AppDbContext db)
|
||||
{
|
||||
public async Task<IResult> GetResultsAsync(Player player)
|
||||
public async Task<IResult> GetResultsAsync(Guid playerId)
|
||||
{
|
||||
var appState = await db.AppState.AsNoTracking().FirstAsync();
|
||||
if (!appState.ResultsOpen)
|
||||
return EndpointHelpers.BadRequestError("Results are locked until the admin enables them.");
|
||||
|
||||
var phase = await EndpointHelpers.GetCurrentPhaseAsync(db, player.Id);
|
||||
var phase = await EndpointHelpers.GetCurrentPhaseAsync(db, playerId);
|
||||
if (phase != Phase.Results)
|
||||
return EndpointHelpers.PhaseMismatch(Phase.Results, phase);
|
||||
|
||||
@@ -33,7 +33,7 @@ internal sealed class ResultsWorkflowService(AppDbContext db)
|
||||
Average = s.Votes.Count == 0 ? 0 : s.Votes.Average(v => v.Score),
|
||||
Votes = s.Votes.Select(v => v.Score).ToList(),
|
||||
MyVote = s.Votes
|
||||
.Where(v => v.PlayerId == player.Id)
|
||||
.Where(v => v.PlayerId == playerId)
|
||||
.Select(v => (int?)v.Score)
|
||||
.FirstOrDefault(),
|
||||
s.ScreenshotUrl,
|
||||
|
||||
Reference in New Issue
Block a user