Exemple #1
0
        /// <summary>
        /// Try to delete the specified product, if product cannot be deleted, return error message "Product Cannot be Deleted"
        /// </summary>
        /// <param name="product">The product to be deleted</param>
        public string DeleteProduct(Product product)
        {
            context.DeleteObject(product);

            try
            {
                context.SaveChanges();
            }
            catch (DataServiceRequestException)
            {
                return("Product Cannot be Deleted");
            }
            return(null);
        }
Exemple #2
0
 public void DeleteProduct(Product product)
 {
     context.Products.Remove(product);
     context.SaveChanges();
 }