This commit is contained in:
parent
f486266bb7
commit
d497e06643
1 changed files with 10 additions and 15 deletions
|
@ -89,24 +89,19 @@ public class AdminController(
|
||||||
[Authenticate("admin:read:reports")]
|
[Authenticate("admin:read:reports")]
|
||||||
[ProducesResults(HttpStatusCode.OK)]
|
[ProducesResults(HttpStatusCode.OK)]
|
||||||
[ProducesErrors(HttpStatusCode.NotFound)]
|
[ProducesErrors(HttpStatusCode.NotFound)]
|
||||||
public async void SetReportState(ReportsQuery query)
|
// ReSharper disable once AsyncVoidMethod
|
||||||
|
public async Task<ReportsQuery>? SetReportState(ReportsQuery query)
|
||||||
{
|
{
|
||||||
try
|
foreach (var list in query.Reports)
|
||||||
{
|
{
|
||||||
foreach (var list in query.Reports)
|
var report = await db.Reports.Where(p => p.Id == list.Id).FirstOrDefaultAsync()
|
||||||
{
|
?? throw GracefulException.NotFound("Report not found");
|
||||||
var report = await db.Reports.Where(p => p.Id == list.Id).FirstOrDefaultAsync()
|
|
||||||
?? throw GracefulException.NotFound("Report not found");
|
|
||||||
|
|
||||||
report.Resolved = list.State is "resolved" or "closed";
|
report.Resolved = list.State is "resolved" or "closed";
|
||||||
|
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
// ReSharper disable once AsyncVoidMethod
|
|
||||||
throw GracefulException.Conflict(e.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue