//Method 01 public void Put(int id, [FromBody] cource cour) { var result = cources.Where(c => id == id).FirstOrDefault(); //(from c in cources // where c.id == id // select c).FirstOrDefault(); result.title = cour.title; }
//Method 01 //public void Post([FromBody]cource c) //{ // c.id = cources.Count; // cources.Add(c); //} //Method 02 public HttpResponseMessage Post([FromBody] cource c) { c.id = cources.Count; cources.Add(c); //should retrn 201 with a location header var msg = Request.CreateResponse(HttpStatusCode.Created); msg.Headers.Location = new Uri(Request.RequestUri + c.id.ToString()); return(msg); }