public IHttpActionResult PostNotesInObject(NotesInObject notesInObject) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.NotesInObjects.Add(notesInObject); try { db.SaveChanges(); } catch (DbUpdateException) { if (NotesInObjectExists(notesInObject.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = notesInObject.Id }, notesInObject); }
public IHttpActionResult PutNotesInObject(Guid id, NotesInObject notesInObject) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != notesInObject.Id) { return BadRequest(); } db.Entry(notesInObject).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!NotesInObjectExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }