// PUT api/MyData/5 public IHttpActionResult PutMyData(int id, MyData mydata) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != mydata.Id) { return BadRequest(); } db.Entry(mydata).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MyDataExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostMyData(MyData mydata) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.MyDatas.Add(mydata); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = mydata.Id }, mydata); }