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; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Update(TEntity obj) { table.Attach(obj); _dbContext.Entry(obj).State = EntityState.Modified; }