public IHttpActionResult PutBug(int id, Bug bug) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != bug.ID) { return BadRequest(); } db.Entry(bug).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BugExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostBug(Bug bug) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Bugs.Add(bug); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = bug.ID }, bug); }