public IHttpActionResult PutWhatDoItem(int id, WhatDoItem whatDoItem) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != whatDoItem.Id) { return BadRequest(); } db.Entry(whatDoItem).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!WhatDoItemExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostWhatDoItem(WhatDoItem whatDoItem) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.WhatDoItems.Add(whatDoItem); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = whatDoItem.Id }, whatDoItem); }