public async Task<IHttpActionResult> PostPlatform(Platform platform) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Platforms.Add(platform); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (PlatformExists(platform.Name)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = platform.Name }, platform); }
public async Task<IHttpActionResult> PutPlatform(string id, Platform platform) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != platform.Name) { return BadRequest(); } db.Entry(platform).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlatformExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }