public IHttpActionResult PutAssessment(int id, Assessment assessment) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != assessment.AssessmentID) { return BadRequest(); } db.Entry(assessment).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AssessmentExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostAssessment(Assessment assessment) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Assessments.Add(assessment); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = assessment.AssessmentID }, assessment); }