Files
Trent 8b1eddb587
CI / backend (push) Successful in 9m43s
CI / frontend (push) Successful in 1m52s
Update to allow for seeding of database
2026-08-11 05:29:51 +08:00

29 lines
1.0 KiB
C#

using Microsoft.EntityFrameworkCore;
/// <summary>
/// Demo site + gateway with fixed GUIDs. Production uses BootstrapSeeder /
/// register-gateway with GATEWAY_ID / GATEWAY_SITE_ID from the environment.
/// </summary>
public static class GatewayRegistrySeeder
{
public static readonly Guid DemoSiteId =
Guid.Parse("11111111-1111-1111-1111-111111111111");
public static readonly Guid DemoGatewayId =
Guid.Parse("22222222-2222-2222-2222-222222222222");
public static async Task SeedAsync(AppDbContext db)
{
if (await db.ClinicalSites.AnyAsync()) return;
var site = new ClinicalSite("SITE-DEMO", "Demo General Hospital", "123 Main St");
db.Entry(site).Property(nameof(ClinicalSite.Id)).CurrentValue = DemoSiteId;
db.ClinicalSites.Add(site);
var gateway = new WardGateway(DemoSiteId, "GW-ICU-3B", "ICU");
db.Entry(gateway).Property(nameof(WardGateway.Id)).CurrentValue = DemoGatewayId;
db.WardGateways.Add(gateway);
await db.SaveChangesAsync();
}
}