public IHttpActionResult PutNoteEdits(int id, NoteEdits noteEdits) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != noteEdits.Id) { return(BadRequest()); } db.Entry(noteEdits).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!NoteEditsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetNoteEdits(int id) { NoteEdits noteEdits = db.NoteEdits.Find(id); if (noteEdits == null) { return(NotFound()); } return(Ok(noteEdits)); }
public IHttpActionResult PostNoteEdits(NoteEdits noteEdits) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.NoteEdits.Add(noteEdits); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = noteEdits.Id }, noteEdits)); }
public IHttpActionResult DeleteNoteEdits(int id) { NoteEdits noteEdits = db.NoteEdits.Find(id); if (noteEdits == null) { return(NotFound()); } db.NoteEdits.Remove(noteEdits); db.SaveChanges(); return(Ok(noteEdits)); }