public JObject deleteProductItem(JObject request)
        {
            //Get arguments
            request.TryGetValue("productItemID", out JToken idValue);
            if (idValue == null || idValue.Type != JTokenType.String)
            {
                return(Templates.MissingArguments("productItemID"));
            }

            string productID = idValue.ToString();

            if (productID == "0")
            {
                return(Templates.InvalidArgument("productID"));
            }

            //Check if productItem exists
            ProductItem item = GetObject <ProductItem>(productID);

            if (item == null)
            {
                return(Templates.NoSuchProduct(productID));
            }
            item.Delete(Connection);

            //Create base response
            return(new JObject()
            {
                { "reason", null },
            });
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Delete a product object and persist changes into the database
 /// </summary>
 /// <param name="productItem"></param>
 public void DeleteProductItem(ProductItem productItem)
 {
     // Remove the object into the database
     productItem.Delete();
 }