public IHttpActionResult PutJob(int id, Job job) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != job.Id) { 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 IHttpActionResult PostJob(Job job) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Jobs.Add(job); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = job.Id }, job); }