public IHttpActionResult PutCourseInformation(int id, CourseInformation courseInformation) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != courseInformation.CourseInformationID) { return BadRequest(); } db.Entry(courseInformation).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CourseInformationExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostCourseInformation(CourseInformation courseInformation) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.CourseInformations.Add(courseInformation); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = courseInformation.CourseInformationID }, courseInformation); }