// POST: odata/JobPosteds public IHttpActionResult Post(JobPosted jobPosted) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.JobPosteds.Add(jobPosted); db.SaveChanges(); return(Created(jobPosted)); }
// DELETE: odata/JobPosteds(5) public IHttpActionResult Delete([FromODataUri] int key) { JobPosted jobPosted = db.JobPosteds.Find(key); if (jobPosted == null) { return(NotFound()); } db.JobPosteds.Remove(jobPosted); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Patch([FromODataUri] int key, Delta <JobPosted> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } JobPosted jobPosted = db.JobPosteds.Find(key); if (jobPosted == null) { return(NotFound()); } patch.Patch(jobPosted); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!JobPostedExists(key)) { return(NotFound()); } else { throw; } } return(Updated(jobPosted)); }