Skip to content
Merged
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
23 changes: 15 additions & 8 deletions api/src/Feature.Form.Submissions/ListMy/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ public override async Task<Results<Ok<Response>, NotFound>> ExecuteAsync(Request
}


var submissions = await context.FormSubmissions.Select(fs => new
var submissions = await context.FormSubmissions
.Where(x =>
x.ElectionRoundId == req.ElectionRoundId
&& x.MonitoringObserver.ElectionRoundId == req.ElectionRoundId
&& x.MonitoringObserver.ObserverId == req.ObserverId)
.Where(x => req.PollingStationIds != null && req.PollingStationIds.Any() &&
req.PollingStationIds.Contains(x.PollingStationId))
.AsNoTracking()
.Select(fs => new
{
fs.Id,
fs.PollingStationId,
Expand All @@ -47,13 +55,14 @@ public override async Task<Results<Ok<Response>, NotFound>> ExecuteAsync(Request
a.IsCompleted && !a.IsDeleted),
NumberOfNotes = context.Notes.Count(n =>
n.SubmissionId == fs.Id && n.MonitoringObserverId == fs.MonitoringObserverId),
}).AsNoTracking()
})
.ToListAsync(ct);


return TypedResults.Ok(new Response
{
Submissions = submissions.Select(entity => new FormSubmissionModel(){
Submissions = submissions.Select(entity => new FormSubmissionModel()
{
Id = entity.Id,
PollingStationId = entity.PollingStationId,
FormId = entity.FormId,
Expand All @@ -64,10 +73,8 @@ public override async Task<Results<Ok<Response>, NotFound>> ExecuteAsync(Request
IsCompleted = entity.IsCompleted,
CreatedAt = entity.CreatedAt,
LastUpdatedAt = entity.LastUpdatedAt,
NumberOfAttachments= entity.NumberOfAttachments,
NumberOfNotes= entity.NumberOfNotes,


NumberOfAttachments = entity.NumberOfAttachments,
NumberOfNotes = entity.NumberOfNotes,
}).ToList()
});
}
Expand Down
Loading