Skip to content

Commit a23fb0e

Browse files
authored
Fix get submissions (#1035)
1 parent d547c2c commit a23fb0e

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

api/src/Feature.Form.Submissions/ListMy/Endpoint.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ public override async Task<Results<Ok<Response>, NotFound>> ExecuteAsync(Request
3131
}
3232

3333

34-
var submissions = await context.FormSubmissions.Select(fs => new
34+
var submissions = await context.FormSubmissions
35+
.Where(x =>
36+
x.ElectionRoundId == req.ElectionRoundId
37+
&& x.MonitoringObserver.ElectionRoundId == req.ElectionRoundId
38+
&& x.MonitoringObserver.ObserverId == req.ObserverId)
39+
.Where(x => req.PollingStationIds != null && req.PollingStationIds.Any() &&
40+
req.PollingStationIds.Contains(x.PollingStationId))
41+
.AsNoTracking()
42+
.Select(fs => new
3543
{
3644
fs.Id,
3745
fs.PollingStationId,
@@ -47,13 +55,14 @@ public override async Task<Results<Ok<Response>, NotFound>> ExecuteAsync(Request
4755
a.IsCompleted && !a.IsDeleted),
4856
NumberOfNotes = context.Notes.Count(n =>
4957
n.SubmissionId == fs.Id && n.MonitoringObserverId == fs.MonitoringObserverId),
50-
}).AsNoTracking()
58+
})
5159
.ToListAsync(ct);
52-
60+
5361

5462
return TypedResults.Ok(new Response
5563
{
56-
Submissions = submissions.Select(entity => new FormSubmissionModel(){
64+
Submissions = submissions.Select(entity => new FormSubmissionModel()
65+
{
5766
Id = entity.Id,
5867
PollingStationId = entity.PollingStationId,
5968
FormId = entity.FormId,
@@ -64,10 +73,8 @@ public override async Task<Results<Ok<Response>, NotFound>> ExecuteAsync(Request
6473
IsCompleted = entity.IsCompleted,
6574
CreatedAt = entity.CreatedAt,
6675
LastUpdatedAt = entity.LastUpdatedAt,
67-
NumberOfAttachments= entity.NumberOfAttachments,
68-
NumberOfNotes= entity.NumberOfNotes,
69-
70-
76+
NumberOfAttachments = entity.NumberOfAttachments,
77+
NumberOfNotes = entity.NumberOfNotes,
7178
}).ToList()
7279
});
7380
}

0 commit comments

Comments
 (0)