public async Task<IHttpActionResult> PostSoundCategory(SoundCategory soundCategory) { if (!this.ModelState.IsValid) return BadRequest(this.ModelState); this.db.SoundCategories.Add(soundCategory); await this.db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new {id = soundCategory.Id}, soundCategory); }
public async Task<IHttpActionResult> PutSoundCategory(int id, SoundCategory soundCategory) { if (!this.ModelState.IsValid) return BadRequest(this.ModelState); if (id != soundCategory.Id) return BadRequest(); this.db.Entry(soundCategory).State = EntityState.Modified; try { await this.db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SoundCategoryExists(id)) return NotFound(); else throw; } return StatusCode(HttpStatusCode.NoContent); }