コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        public IHttpActionResult GetvPosition(int id)
        {
            vPosition vPosition = db.vPositions.Find(id);

            if (vPosition == null)
            {
                return(NotFound());
            }

            return(Ok(vPosition));
        }