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