Example #1
0
        public static void Initialize(IApplicationBuilder app)
        {
            using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                var context = serviceScope.ServiceProvider.GetService <HealthContext>();
                context.Database.EnsureCreated();
                //context.Database.Migrate();

                // Look for any Patients
                if (context.users != null && context.users.Any())
                {
                    return;   // DB has already been seeded
                }
                var items = DummyData.Getitems().ToArray();
                context.items.AddRange(items);
                context.SaveChanges();

                var users = DummyData.Getusers(context).ToArray();
                context.users.AddRange(users);
                context.SaveChanges();
            }
        }
Example #2
0
        public static void Initialize(IApplicationBuilder app)
        {
            using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                var context = serviceScope.ServiceProvider.GetService <HealthContext>();
                context.Database.EnsureCreated();

                var clinicians = DummyData.GetClinicians().ToArray();
                context.Clinicians.AddRange(clinicians);
                context.SaveChanges();

                var medicines = DummyData.GetMedicines().ToArray();
                context.Medicines.AddRange(medicines);
                context.SaveChanges();

                var patients = DummyData.GetPatients().ToArray();
                context.Patients.AddRange(patients);
                context.SaveChanges();

                var bloodPressures = DummyData.GetBloodPressures().ToArray();
                context.BloodPressures.AddRange(bloodPressures);
                context.SaveChanges();

                var bodyHeats = DummyData.GetBodyHeats().ToArray();
                context.BodyHeats.AddRange(bodyHeats);
                context.SaveChanges();

                var respiratoryRates = DummyData.GetRespiratoryRates().ToArray();
                context.RespiratoryRates.AddRange(respiratoryRates);
                context.SaveChanges();

                var sinusRhythms = DummyData.GetSinusRhythms().ToArray();
                context.SinusRhythms.AddRange(sinusRhythms);
                context.SaveChanges();

                var appointments = DummyData.GetAppointments().ToArray();
                context.Appointments.AddRange(appointments);
                context.SaveChanges();

                var watchLists = DummyData.GetWatchLists().ToArray();
                context.WatchLists.AddRange(watchLists);
                context.SaveChanges();

                var images = DummyData.GetImages().ToArray();
                context.Images.AddRange(images);
                context.SaveChanges();

                var diagnoses = DummyData.GetDiagnoses().ToArray();
                context.Diagnoses.AddRange(diagnoses);
                context.SaveChanges();

                var observedItems = DummyData.GetObservedItems(context).ToArray();
                context.ObservedItems.AddRange(observedItems);
                context.SaveChanges();

                var observations = DummyData.GetObservations(context).ToArray();
                context.Observations.AddRange(observations);
                context.SaveChanges();

                var medications = DummyData.GetMedications(context).ToArray();
                context.Medications.AddRange(medications);
                context.SaveChanges();

                var reports = DummyData.GetReports(context).ToArray();
                context.Reports.AddRange(reports);
                context.SaveChanges();
            }
        }