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