public async Task<IHttpActionResult> PutCourseScedule(int id, CourseScedule courseScedule) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != courseScedule.CourseSceduleId) { return BadRequest(); } db.Entry(courseScedule).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseSceduleExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostCourseScedule(CourseScedule courseScedule) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.CourseScedules.Add(courseScedule); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = courseScedule.CourseSceduleId }, courseScedule); }