public HttpResponseMessage Put(int id, Person person) { PersonContext db = new PersonContext(); if (!ModelState.IsValid) { return Request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } if (id != person.ID) { return Request.CreateResponse(HttpStatusCode.BadRequest); } db.Entry(person).State = EntityState.Modified; db.SaveChanges(); return Request.CreateResponse(HttpStatusCode.OK); }
public HttpResponseMessage Post(Person person) { PersonContext db = new PersonContext(); if (ModelState.IsValid) { db.People.Add(person); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, person); return response; } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }