public async Task<IHttpActionResult> PutExerciseAttribute(long id, ExerciseAttribute exerciseAttribute) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != exerciseAttribute.Id) { return BadRequest(); } if (db.Entry(exerciseAttribute).Entity.Exercise.Set.AspNetUser.Id.ToLower().CompareTo(user.Id.ToLower()) != 0) return NotFound(); db.Entry(exerciseAttribute).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ExerciseAttributeExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostExerciseAttribute(ExerciseAttribute exerciseAttribute) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.ExerciseAttributes.Add(exerciseAttribute); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = exerciseAttribute.Id }, exerciseAttribute); }