public IHttpActionResult PutJob(int id, Job job)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != job.JobID)
            {
                return BadRequest();
            }

            db.Entry(job).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!JobExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public Job CreateJob(Job job)
        {
            db.Jobs.Add(job);
            db.SaveChanges();

            return job;
        }
        public IHttpActionResult PostJob(Job job)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Jobs.Add(job);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = job.JobID }, job);
        }
        public void UpdateJob(int id, Job job)
        {
            db.Entry(job).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
Exemple #5
0
        /// <summary>
        /// Converts this instance of <see cref="JobDTO"/> to an instance of <see cref="Job"/>.
        /// </summary>
        /// <param name="dto"><see cref="JobDTO"/> to convert.</param>
        public static Job ToEntity(this JobDTO dto)
        {
            if (dto == null) return null;

            var entity = new Job();

            entity.JobID = dto.JobID;
            entity.BusinessID = dto.BusinessID;
            entity.Title = dto.Title;
            entity.Description = dto.Description;
            entity.JobTypeID = dto.JobTypeID;
            entity.IsActive = dto.IsActive;
            entity.IsDeleted = dto.IsDeleted;
            entity.StartDate = dto.StartDate;
            entity.EndDate = dto.EndDate;
            entity.insuser = dto.insuser;
            entity.insdt = dto.insdt;
            entity.upduser = dto.upduser;
            entity.upddt = dto.upddt;

            dto.OnEntity(entity);

            return entity;
        }
Exemple #6
0
 /// <summary>
 /// Invoked when <see cref="ToEntity"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="Job"/> converted from <see cref="JobDTO"/>.</param>
 static partial void OnEntity(this JobDTO dto, Job entity);