public async Task<IHttpActionResult> PutRoutePoint(Guid id, RoutePoint routePoint) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != routePoint.RoutePointId) { return BadRequest(); } db.Entry(routePoint).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoutePointExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostRoutePoint(RoutePoint routePoint) { if (!ModelState.IsValid) { return BadRequest(ModelState); } routePoint.RoutePointId = Guid.NewGuid(); db.RoutePoints.Add(routePoint); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (RoutePointExists(routePoint.RoutePointId)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = routePoint.RoutePointId }, routePoint); }