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

            if (id != bDescription.billet_id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult Get(int id)
        {
            BDescription bDescription = db.BDescriptions.Find(id);

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

            return(Ok(bDescription));
        }
コード例 #3
0
        public IHttpActionResult Post(BDescription bDescription)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.BDescriptions.Add(bDescription);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = bDescription.billet_id }, bDescription));
        }
コード例 #4
0
        public IHttpActionResult Delete(int id)
        {
            BDescription bDescription = db.BDescriptions.Find(id);

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

            db.BDescriptions.Remove(bDescription);
            db.SaveChanges();

            return(Ok(bDescription));
        }