-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathGetAlertsRequestHandler.cs
More file actions
38 lines (32 loc) · 1.07 KB
/
GetAlertsRequestHandler.cs
File metadata and controls
38 lines (32 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using Microsoft.EntityFrameworkCore;
using OpenAlprWebhookProcessor.Data;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace OpenAlprWebhookProcessor.Alerts
{
public class GetAlertsRequestHandler
{
private readonly ProcessorContext _processorContext;
public GetAlertsRequestHandler(ProcessorContext processorContext)
{
_processorContext = processorContext;
}
public async Task<List<Alert>> HandleAsync(CancellationToken cancellationToken)
{
var alerts = new List<Alert>();
foreach (var dbAlert in await _processorContext.Alerts.ToListAsync(cancellationToken))
{
var alert = new Alert()
{
Id = dbAlert.Id,
PlateNumber = dbAlert.PlateNumber,
StrictMatch = dbAlert.IsStrictMatch,
Description = dbAlert.Description,
};
alerts.Add(alert);
}
return alerts;
}
}
}