public override void EnsureSeeded() { var csvConfig = new CsvConfiguration { Delimiter = "|", SkipEmptyRecords = true, TrimFields = true, TrimHeaders = true, WillThrowOnMissingField = false }; SeederConfiguration.ResetConfiguration(csvConfig, null, typeof(SettingsContext).GetTypeInfo().Assembly); Dockets.SeedDbSetIfEmpty($"{nameof(Dockets)}"); CentralRegistries.SeedDbSetIfEmpty($"{nameof(CentralRegistries)}"); EmrSystems.SeedDbSetIfEmpty($"{nameof(EmrSystems)}"); DatabaseProtocols.SeedDbSetIfEmpty($"{nameof(DatabaseProtocols)}"); RestProtocols.SeedDbSetIfEmpty($"{nameof(RestProtocols)}"); Resources.SeedDbSetIfEmpty($"{nameof(Resources)}"); var ex = Extracts.Where(e => e.EmrSystemId.ToString() == "a62216ee-0e85-11e8-ba89-0ed5f89f718b" || e.EmrSystemId.ToString() == "a6221856-0e85-11e8-ba89-0ed5f89f718b" || e.EmrSystemId.ToString() == "a6221857-0e85-11e8-ba89-0ed5f89f718b" ); Extracts.RemoveRange(ex); Extracts.SeedFromResource($"{nameof(Extracts)}"); SaveChanges(); }
public override void EnsureSeeded() { var managedEmrs = new List <Guid> { new Guid("a62216ee-0e85-11e8-ba89-0ed5f89f718b"), new Guid("a6221856-0e85-11e8-ba89-0ed5f89f718b"), new Guid("a6221857-0e85-11e8-ba89-0ed5f89f718b"), new Guid("926f49b8-305d-11ea-978f-2e728ce88125"), new Guid("a6221860-0e85-11e8-ba89-0ed5f89f718b") }; this.SeedMerge <Docket>(typeof(SettingsContext).Assembly, "|", "Seed", $"{nameof(Dockets)}").Wait(); this.SeedMerge <CentralRegistry>(typeof(SettingsContext).Assembly, "|", "Seed", $"{nameof(CentralRegistries)}").Wait(); this.SeedNewOnly <EmrSystem>(typeof(SettingsContext).Assembly, "|", "Seed", $"{nameof(EmrSystems)}").Wait(); this.SeedNewOnly <DatabaseProtocol>(typeof(SettingsContext).Assembly, "|", "Seed", $"{nameof(DatabaseProtocols)}").Wait(); var restEndpoints = RestProtocols.AsNoTracking().ToList(); if (restEndpoints.All(x => x.Url.Contains("https://palladiumkenya.github.io/dwapi/stuff"))) { this.SeedMerge <RestProtocol>(typeof(SettingsContext).Assembly, "|", "Seed", $"{nameof(RestProtocols)}") .Wait(); this.SeedMerge <Resource>(typeof(SettingsContext).Assembly, "|", "Seed", $"{nameof(Resources)}").Wait(); } else { this.SeedNewOnly <RestProtocol>(typeof(SettingsContext).Assembly, "|", "Seed", $"{nameof(RestProtocols)}").Wait(); this.SeedNewOnly <Resource>(typeof(SettingsContext).Assembly, "|", "Seed", $"{nameof(Resources)}") .Wait(); } managedEmrs.ForEach(x => { var sql = $"DELETE FROM {nameof(Extracts)} WHERE {nameof(Extract.EmrSystemId)} = '{x}'"; Database.ExecuteSqlCommand(sql); }); this.SeedNewOnly <Extract>(typeof(SettingsContext).Assembly, "|", "Seed", $"{nameof(Extracts)}").Wait(); this.SeedMerge <IntegrityCheck>(typeof(SettingsContext).Assembly, ",", "Seed", $"{nameof(IntegrityChecks)}").Wait(); this.SeedMerge <IndicatorKey>(typeof(SettingsContext).Assembly, ",", "Seed", $"{nameof(IndicatorKeys)}").Wait(); }
public void AddRestProtocol(RestProtocol protocol) { protocol.EmrSystemId = Id; RestProtocols.Add(protocol); }