public async Task<IHttpActionResult> PutAchievement(int id, Achievement achievement) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != achievement.Id) { return BadRequest(); } _db.Entry(achievement).State = EntityState.Modified; try { await _db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AchievementExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostAchievement(Achievement achievement) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _db.Achievements.Add(achievement); await _db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = achievement.Id }, achievement); }