public async Task<IHttpActionResult> PutCommunity(int id, Community community) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != community.Id) { return BadRequest(); } db.Entry(community).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommunityExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostCommunity(Community community) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Communities.Add(community); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = community.Id }, community); }