public IHttpActionResult PutSubjectNote(int id, SubjectNote subjectNote) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != subjectNote.Id) { return BadRequest(); } db.Entry(subjectNote).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SubjectNoteExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostSubjectNote(SubjectNote subjectNote) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.SubjectNotes.Add(subjectNote); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = subjectNote.Id }, subjectNote); }