public IHttpActionResult UpdateTask(int id, [FromBody] Task task) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != task.TaskID) { return(BadRequest()); } dbContext.Entry(task).State = EntityState.Modified; try { dbContext.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TaskExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IActionResult Put(int id, [FromBody] ToDoTask task) { context.Entry(task).State = EntityState.Modified; context.SaveChanges(); return(Ok()); }