コード例 #1
0
        public IHttpActionResult PutA1Data(int id, A1Data a1Data)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != a1Data.Id)
            {
                return(BadRequest());
            }

            db.Entry(a1Data).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!A1DataExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult GetA1Data(int id)
        {
            A1Data a1Data = db.A1Data.Find(id);

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

            return(Ok(a1Data));
        }
コード例 #3
0
        public IHttpActionResult PostA1Data(A1Data a1Data)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.A1Data.Add(a1Data);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = a1Data.Id }, a1Data));
        }
コード例 #4
0
        public IHttpActionResult DeleteA1Data(int id)
        {
            A1Data a1Data = db.A1Data.Find(id);

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

            db.A1Data.Remove(a1Data);
            db.SaveChanges();

            return(Ok(a1Data));
        }