public async Task<IHttpActionResult> PutLocation(int id, Location location) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != location.Id) { return BadRequest(); } db.Entry(location).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LocationExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostLocation(Location location) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Locations.Add(location); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = location.Id }, location); }