public 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 { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!activityExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult Postactivity(activity activity) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.activity.Add(activity); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = activity.activityId }, activity); }