Beispiel #1
0
 public bool Delete(SubContractorJob c)
 {
     using (var db = DBConnection.GetConnection())
     {
         return(SubContractorJob.Delete <SubContractorJob>(db, c));
     }
 }
Beispiel #2
0
 public bool Post([FromBody] SubContractorJob c)
 {
     using (var db = DBConnection.GetConnection())
     {
         return(SubContractorJob.Persist <SubContractorJob>(db, c));
     }
 }
Beispiel #3
0
 public SubContractorJob Get(int id)
 {
     using (var db = DBConnection.GetConnection())
     {
         return(SubContractorJob.GetById <SubContractorJob>(db, id));
     }
 }
Beispiel #4
0
 public IEnumerable <SubContractorJob> Get()
 {
     using (var db = DBConnection.GetConnection())
     {
         return(SubContractorJob.GetAll <SubContractorJob>(db));
     }
 }
        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);
        }
        /// <summary>
        /// Builds an instance of a SubContractorJob ('Is a' ProjectComponent) from a Sql Data Reader object
        /// </summary>
        /// <param name="reader"></param>
        /// <returns>Instance of a <strong>SubContractorJob</strong></returns>
        public static SubContractorJob BuildSubcontractorJobModel(SqlDataReader reader)
        {
            var job = new SubContractorJob()
            {
                Id                   = DbUtilities.GetInt(reader, "ProjectComponentId"),
                ProjectId            = DbUtilities.GetInt(reader, "ProjectId"),
                ComponentName        = DbUtilities.GetString(reader, "ProjectComponentName"),
                ComponentDescription = DbUtilities.GetString(reader, "ComponentDescription"),
                SubcontractorId      = DbUtilities.GetNullableInt(reader, "SubcontractorId"),
                DateComplete         = DbUtilities.GetNullableDateTime(reader, "PCDateComplete"),
                MaterialCost         = DbUtilities.GetInt(reader, "MaterialCost"),
                OwnerScreenName      = DbUtilities.GetString(reader, "ScreenName"),
                OwnerImageUrl        = DbUtilities.GetString(reader, "ImageLocation"),
                ProjectName          = DbUtilities.GetString(reader, "ProjectName"),
                LocationName         = DbUtilities.GetString(reader, "LocationName"),
                LocationAddress      = DbUtilities.GetString(reader, "LocationAddress"),
                SubcontractorFee     = DbUtilities.GetInt(reader, "Fee"),
            };

            return(job);
        }