public void SetDatesToToday(int daysChange, ClinicalStudyContext dbContext)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            foreach (var patient in dbContext.Set<Patient>()) {
                patient.EnrollDate = AddDays(daysChange, patient.EnrollDate);
                patient.RandomisationDate = AddDays(daysChange, patient.RandomisationDate);
            }

            foreach (var visit in dbContext.Set<Visit>()) {
                visit.VisitDate = AddDays(daysChange, visit.VisitDate);
                visit.ExpectedVisitDate = AddDays(daysChange, visit.ExpectedVisitDate);
            }

            foreach (var question in dbContext.Set<RepeatableInventoryData>().Select(rid => rid.DateUsed)) {
                question.Value = AddDays(daysChange, question.Value);
            }

            foreach (var formData in dbContext.Set<InventoryFormData>()) {
                formData.ReceiptDate.Value = AddDays(daysChange, formData.ReceiptDate.Value);
                formData.ShipDate.Value = AddDays(daysChange, formData.ShipDate.Value);
            }

            foreach (var query in dbContext.Set<Query>()) {
                query.QueryTime = AddDays(daysChange, query.QueryTime);
                query.AnswerTime = AddDays(daysChange, query.AnswerTime);
            }

            foreach (var changeNote in dbContext.Set<ChangeNote>()) {
                changeNote.ChangeDate = AddDays(daysChange, changeNote.ChangeDate);
            }

            dbContext.SaveChanges();
            stopwatch.Stop();
        }
        public void TestCreation()
        {
            Database.SetInitializer(new DropCreateDatabaseAlways<ClinicalStudyContext>());
            var connectionString = ConfigurationManager.ConnectionStrings["ClinicalStudyContext"].ConnectionString;

            ClinicalStudyContext db = new ClinicalStudyContext(connectionString);
            var x = db.Users.FirstOrDefault();
        }
 public InMemoryPerSessionInitialisator(ClinicalStudyContext dbContext)
 {
     this.dbContext = dbContext;
 }
 public int GetDaysChange(ClinicalStudyContext dbContext)
 {
     var timepoint = dbContext.Timepoints.First();
     var timeSpan = DateTime.Now.Date - timepoint.DateAndTime.Date;
     return (int)timeSpan.TotalDays;
 }