Beispiel #1
0
 public SubContractorJob Get(int id)
 {
     using (var db = DBConnection.GetConnection())
     {
         return(SubContractorJob.GetById <SubContractorJob>(db, id));
     }
 }
        public void SubJobDBOperationsTest()
        {
            IDbConnection db = DBConnection.GetConnection();

            SubContractorJob s1 = new SubContractorJob()
            {
                SubContractorId = 5,
                JobId           = 9,
                StartDate       = DateTime.Today,
                EndDate         = null,
                EstimatedCost   = 30000,
                ActualCost      = 15000,
                WhenCreated     = SubContractorJob.GetById <SubContractorJob>(db, 1).WhenCreated
            };


            SubContractorJob s2 = new SubContractorJob()
            {
                SubContractorId = 6,
                JobId           = 9,
                StartDate       = DateTime.Today,
                EndDate         = DateTime.Today.AddDays(5),
                EstimatedCost   = 12000,
                ActualCost      = 15000,
                WhenCreated     = SubContractorJob.GetById <SubContractorJob>(db, 2).WhenCreated
            };

            SubContractorJob s3 = new SubContractorJob()
            {
                SubContractorId = 6,
                JobId           = 8,
                StartDate       = DateTime.Today,
                EndDate         = DateTime.Today.AddDays(10),
                EstimatedCost   = 20000,
                ActualCost      = 18000,
                IsDeleted       = true,
                WhenCreated     = SubContractorJob.GetById <SubContractorJob>(db, 3).WhenCreated
            };

            //what is the value of IsDeleted by default?
            TestContext.Out.WriteLine("Value of IsDeleted: " + s2.IsDeleted);

            SubContractorJob.Persist <SubContractorJob>(db, s1);
            SubContractorJob.Persist <SubContractorJob>(db, s2);
            SubContractorJob.Persist <SubContractorJob>(db, s3);
        }