// PUT api/OnMyWay/5 public IHttpActionResult PutOnMyWay(int id, OnMyWay onmyway) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != onmyway.onMyWayId) { return(BadRequest()); } db.Entry(onmyway).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OnMyWayExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetOnMyWay(int id) { OnMyWay onmyway = db.OnMyWays.Find(id); if (onmyway == null) { return(NotFound()); } return(Ok(onmyway)); }
public IHttpActionResult PostOnMyWay(OnMyWay onmyway) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.OnMyWays.Add(onmyway); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = onmyway.onMyWayId }, onmyway)); }
public IHttpActionResult DeleteOnMyWay(int id) { OnMyWay onmyway = db.OnMyWays.Find(id); if (onmyway == null) { return(NotFound()); } db.OnMyWays.Remove(onmyway); db.SaveChanges(); return(Ok(onmyway)); }