public async Task<IHttpActionResult> PutActivity(int id, Activity activity) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != activity.ActivityID) { return BadRequest(); } db.Entry(activity).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ActivityExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostActivity(Activity activity) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Activity.Add(activity); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = activity.ActivityID }, activity); }