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

                if (context.Ailments != null && context.Ailments.Any())
                {
                    return;
                }

                var ailments = DummyData.GetAilments().ToArray();
                context.Ailments.AddRange(ailments);
                context.SaveChanges();

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

                var patients = DummyData.GetPatients(context).ToArray();
                context.Patients.AddRange(patients);
                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();
            }
        }