public async Task<IHttpActionResult> PutStudentCourse(int id, StudentCourse studentCourse) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != studentCourse.StudentCourseId) { return BadRequest(); } db.Entry(studentCourse).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentCourseExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostStudentCourse(StudentCourse studentCourse) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.StudentCourses.Add(studentCourse); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = studentCourse.StudentCourseId }, studentCourse); }