public async Task<IHttpActionResult> PutCourse(int id, Course course) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != course.Id) { return BadRequest(); } //db.Entry(course).State = EntityState.Modified; db.MarkAsModified(course); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostCourse(Course course) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Courses.Add(course); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = course.Id }, course); }
public void MarkAsModified(Course course) { Entry(course).State = EntityState.Modified; }
public void MarkAsModified(SpaTest.Models.Course course) { }