Esempio n. 1
0
        private void SeedPatient(PatientViewModel[] patientList)
        {
            using (IServiceScope scope = this.server.Host.Services.GetService <IServiceScopeFactory>().CreateScope())
            {
                IMapper mapper = this.server.Host.Services.GetService <IMapper>();
                using (SeedDotnetContext context = scope.ServiceProvider.GetRequiredService <SeedDotnetContext>())
                {
                    foreach (PatientViewModel patient in patientList)
                    {
                        context.Patients.Add(mapper.Map <Patient>(patient));
                    }

                    context.SaveChanges();
                }
            }
        }
Esempio n. 2
0
        private void ClearPatientData()
        {
            using (IServiceScope scope = this.server.Host.Services.GetService <IServiceScopeFactory>().CreateScope())
            {
                using (SeedDotnetContext context = scope.ServiceProvider.GetRequiredService <SeedDotnetContext>())
                {
                    List <Patient> patients = context.Patients.ToList();

                    foreach (Patient patient in patients)
                    {
                        context.Patients.Remove(patient);
                    }

                    context.SaveChanges();
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="context"></param>
 public UnitOfWork(SeedDotnetContext context)
 {
     this.context   = context;
     this.Patients  = new PatientRepository(this.context);
     this.Allergies = new AllergyRepository(this.context);
 }
Esempio n. 4
0
 /// <summary>
 ///     Set the context of the app
 /// </summary>
 /// <param name="_context"></param>
 public RepositoryBase(SeedDotnetContext _context)
 {
     this.context = _context;
 }
 /// <summary>
 /// Set the context of the app
 /// </summary>
 /// <param name="_context"></param>
 public SeedDotnetRepository(SeedDotnetContext _context)
 {
     this.context = _context;
 }
Esempio n. 6
0
 public AllergyRepository(SeedDotnetContext context)
     : base(context)
 {
 }
Esempio n. 7
0
 public PatientRepository(SeedDotnetContext context)
     : base(context)
 {
 }