// PUT api/PeopleLocation/5 public HttpResponseMessage PutPeopleLocation(int id, erPeopleLocation peoplelocation) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } if (id != peoplelocation.Id) { return Request.CreateResponse(HttpStatusCode.BadRequest); } db.Entry(peoplelocation).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex); } return Request.CreateResponse(HttpStatusCode.OK); }
// POST api/PeopleLocation public HttpResponseMessage PostPeopleLocation(erPeopleLocation peoplelocation) { if (ModelState.IsValid) { db.PeopleLocations.Add(peoplelocation); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, peoplelocation); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = peoplelocation.Id })); return response; } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }