public IHttpActionResult PostExercise2(Exercise2 exercise2) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Exercise2.Add(exercise2); try { db.SaveChanges(); } catch (DbUpdateException) { if (Exercise2Exists(exercise2.user_id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = exercise2.user_id }, exercise2); }
public IHttpActionResult PutExercise2(int id, Exercise2 exercise2) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != exercise2.user_id) { return BadRequest(); } db.Entry(exercise2).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Exercise2Exists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }