public IHttpActionResult PutAssignment(int id, Assignment assignment) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != assignment.AssignmentID) { return BadRequest(); } db.Entry(assignment).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AssignmentExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostAssignment(Assignment assignment) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Assignments.Add(assignment); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = assignment.AssignmentID }, assignment); }