public async Task<IHttpActionResult> CreateCourse(Course course) { course.ClientId = this.ClientId; if (!this.ModelState.IsValid) { return this.BadRequest(this.ModelState); } this.db.Courses.Add(course); this.db.SaveChanges(); return this.Ok(course); }
public async Task<IHttpActionResult> UpdateCourse(int id, Course course) { course.ClientId = this.ClientId; if (!this.ModelState.IsValid) { return this.BadRequest(this.ModelState); } this.db.Entry(course).State = EntityState.Modified; try { this.db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!this.CourseExists(id)) { return this.NotFound(); } throw; } return this.StatusCode(HttpStatusCode.NoContent); }