public IHttpActionResult PutCourse(int id, Course course) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != course.Id) { return BadRequest(); } db.Entry(course).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostCourse(Course course) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Courses.Add(course); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = course.Id }, course); }