-
Notifications
You must be signed in to change notification settings - Fork 0
/
Api.cs
45 lines (34 loc) · 1.26 KB
/
Api.cs
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
39
40
41
42
43
44
45
using DataAccessLayer.Data;
using DataAccessLayer.MessageTypes.Common;
using DataAccessLayer.MessageTypes;
using Hangfire;
using Microsoft.Extensions.Options;
namespace SmartCare;
public static class Api
{
public static void ConfigureApi(this WebApplication app )
{
app.MapPost("/Patient", ProcessRequest);
}
private static IResult ProcessRequest(
AbstractPatientMessage patient,
IProcessMessage repository,
IOptions<AppSettingsMessageTypes> config)
{
MESSAGEHEADER? msgHeader = patient.MESSAGE_HEADER;
msgHeader = msgHeader ?? throw new ArgumentNullException(nameof(msgHeader));
if (msgHeader.MESSAGE_TYPE == config.Value.PatientRegistration)
{
var jobId = BackgroundJob.Schedule(() => repository.RegisterPatient(patient),
TimeSpan.FromSeconds(3));
}
if(msgHeader.MESSAGE_TYPE == "RDE^001")
{
var job= BackgroundJob.Schedule(() => repository.CreatePhamarcyOrder(patient),
TimeSpan.FromSeconds(3));
var job2 = BackgroundJob.Schedule(() => repository.PopulatePharmarcyOrder(patient),
TimeSpan.FromSeconds(3));
}
return Results.Ok(msgHeader);
}
}