// PUT api/ToDoTask/5 public IHttpActionResult PutToDoTask(int id, ToDoTask todotask) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != todotask.ID) { return BadRequest(); } db.Entry(todotask).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ToDoTaskExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostToDoTask(ToDoTask todotask) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Tasks.Add(todotask); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = todotask.ID }, todotask); }