示例#1
0
        public IHttpActionResult PutProductsJohn(int id, ProductsJohn productsJohn)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != productsJohn.ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public IHttpActionResult GetProductsJohn(int id)
        {
            ProductsJohn productsJohn = db.ProductsJohn.Find(id);

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

            return(Ok(productsJohn));
        }
示例#3
0
        public IHttpActionResult PostProductsJohn(ProductsJohn productsJohn)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ProductsJohn.Add(productsJohn);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = productsJohn.ID }, productsJohn));
        }
示例#4
0
        public IHttpActionResult DeleteProductsJohn(int id)
        {
            ProductsJohn productsJohn = db.ProductsJohn.Find(id);

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

            db.ProductsJohn.Remove(productsJohn);
            db.SaveChanges();

            return(Ok(productsJohn));
        }