public IHttpActionResult PutNote(int id, Note note) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != note.Id) { return BadRequest(); } db.Entry(note).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!NoteExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostNote(Note note) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Notes.Add(note); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = note.Id }, note); }