public IHttpActionResult PutNoteTag(int id, NoteTag noteTag) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != noteTag.Id) { return BadRequest(); } db.Entry(noteTag).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!NoteTagExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostNoteTag(NoteTag noteTag) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.NoteTags.Add(noteTag); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = noteTag.Id }, noteTag); }