public void PutInstructor(int id, Instructor instr) { instr.Id = id; dbCtxt.Instructors.Attach(instr); dbCtxt.Entry(instr).State = System.Data.EntityState.Modified; dbCtxt.SaveChanges(); }
public HttpResponseMessage PostInstructor(Instructor instr) { if (!ModelState.IsValid) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, this.ModelState)); } dbCtxt.Instructors.Add(instr); int records = dbCtxt.SaveChanges(); var response = Request.CreateResponse(HttpStatusCode.Created, instr); response.Headers.Location = new Uri(Url.Link(ODataRouteNames.GetById, new { Controller = "Instructors", Id = instr.Id })); return response; }