public async Task <Biochemistry> SaveBiochemistryAsync(Biochemistry biochemistry)
 {
     using (var txScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
     {
         if (biochemistry.IsNew)
         {
             await AddBiochemistryAsync(biochemistry);
         }
         else
         {
             await UpdateBiochemistryAsync(biochemistry);
         }
         // One To One
         if (biochemistry.Patient != null)
         {
             if (biochemistry.Patient.IsDeleted)
             {
                 var id = biochemistry.Patient.PatientID;
                 await Conn.DeleteByIdAsync <Patient>(id);
             }
             else if (!biochemistry.Patient.IsDeleted)
             {
                 var patient = biochemistry.Patient;
                 patient.PatientID = biochemistry.SerialNo;
                 await Conn.SaveAsync(patient);
             }
         }
         txScope.Complete();
     }
     return(biochemistry);
 }
        public async Task <Biochemistry> AddBiochemistryAsync(Biochemistry biochemistry)
        {
            await Conn.InsertAsync(biochemistry);

            biochemistry.SerialNo = Conn.LastInsertId();
            return(biochemistry);
        }
Beispiel #3
0
        public void CreateCSV(int numberOfRecords)
        {
            var r      = new Random(500);
            var people = new PersonCollection();

            people.GeneratePeople(100, r);

            var f = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "DeleteMeTestBiochemistry.csv"));

            bool finished            = false;
            int  finishedWithRecords = -1;

            var biochem = new Biochemistry(new Random(500));

            biochem.RowsGenerated += (s, e) =>
            {
                finished            = e.IsFinished;
                finishedWithRecords = e.RowsWritten;
            };

            biochem.GenerateTestDataFile(people, f, numberOfRecords);

            //one progress task only, should have reported creating the correct number of rows
            Assert.IsTrue(finished);
            Assert.AreEqual(numberOfRecords, finishedWithRecords);

            Assert.GreaterOrEqual(File.ReadAllLines(f.FullName).Length, numberOfRecords);//can be newlines in middle of file

            Console.WriteLine("Created file: " + f.FullName);
            f.Delete();
        }
 public Biochemistry SaveBiochemistry(Biochemistry biochemistry)
 {
     using (var txScope = new TransactionScope())
     {
         if (biochemistry.IsNew)
         {
             AddBiochemistry(biochemistry);
         }
         else
         {
             UpdateBiochemistry(biochemistry);
         }
         // One To One
         if (biochemistry.Patient != null)
         {
             var patient = biochemistry.Patient;
             patient.PatientID = biochemistry.SerialNo;
             Conn.Save(patient);
         }
         txScope.Complete();
     }
     return(biochemistry);
 }
 public async Task <Biochemistry> SaveBiochemistryAsync(Biochemistry biochemistry)
 {
     return(null);
 }
        public Biochemistry UpdateBiochemistry(Biochemistry biochemistry)
        {
            var result = Conn.Update(biochemistry);

            return(biochemistry);
        }
 public Task <Biochemistry> AddBiochemistryAsync(Biochemistry biochemistry)
 {
     return(null);
 }
 public Biochemistry AddBiochemistry(Biochemistry biochemistry)
 {
     Conn.Insert(biochemistry);
     biochemistry.SerialNo = Conn.LastInsertId();
     return(biochemistry);
 }
 public Biochemistry SaveBiochemistry(Biochemistry biochemistry)
 {
     return(null);
 }
 public Biochemistry UpdateBiochemistry(Biochemistry biochemistry)
 {
     return(null);
 }
 public Biochemistry AddBiochemistry(Biochemistry biochemistry)
 {
     return(null);
 }
        public async Task <Biochemistry> UpdateBiochemistryAsync(Biochemistry biochemistry)
        {
            await Conn.UpdateAsync(biochemistry);

            return(biochemistry);
        }