コード例 #1
0
        public async Task<IHttpActionResult> Postcart_product(cart_product cart_product)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.sp_cart_product_insert(cart_product.cart_id, cart_product.product_id, cart_product.quantity);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (cart_productExists(cart_product.cart_id))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = cart_product.cart_id }, cart_product);
        }
コード例 #2
0
        public async Task<IHttpActionResult> Putcart_product(int id, cart_product cart_product)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != cart_product.cart_id)
            {
                return BadRequest();
            }

            return Ok( db.sp_cart_product_updateByCartIDAndProductID(id, cart_product.product_id, cart_product.quantity) );

        }