// POST api/Fees public HttpResponseMessage Post(Fee fee) { if (ModelState.IsValid) { db.Fees.Add(fee); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, fee); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = fee.id })); return response; } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
// PUT api/Fees/5 public HttpResponseMessage Put(int id, Fee fee) { if (ModelState.IsValid && id == fee.id) { db.Fees.Attach(fee); db.Entry(fee).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.NotFound); } return Request.CreateResponse(HttpStatusCode.OK); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }