public IHttpActionResult PutvPosition(int id, vPosition vPosition) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != vPosition.PositionsID) { return(BadRequest()); } db.Entry(vPosition).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!vPositionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostvPosition(vPosition vPosition) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.vPositions.Add(vPosition); try { db.SaveChanges(); } catch (DbUpdateException) { if (vPositionExists(vPosition.PositionsID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = vPosition.PositionsID }, vPosition)); }
public IHttpActionResult GetvPosition(int id) { vPosition vPosition = db.vPositions.Find(id); if (vPosition == null) { return(NotFound()); } return(Ok(vPosition)); }