// POST api/<controller> public HttpResponseMessage Post(Hello hello) { db.Helloes.Add(hello); db.SaveChanges(); var response = Request.CreateResponse<Hello>(HttpStatusCode.Created, hello); string uri = Url.Link("DefaultApi", new { id = hello.helloID }); response.Headers.Location = new Uri(uri); return response; }
public HttpResponseMessage Put(string put, Hello hello) { if (ModelState.IsValid) { db.Entry(hello).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.NotFound); } return Request.CreateResponse<Hello>(HttpStatusCode.OK,hello); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }