Ejemplo n.º 1
0
        /// <summary>
        /// Deletes a user product.
        /// </summary>
        /// <param name="user_product"></param>
        /// <param name="instance_use"></param>
        /// <returns>string</returns>
        public string Delete(UserProduct user_product, string instance_use)
        {
            string result;

            switch (instance_use)
            {
            case "Username":
                result = db_userproduct.DeleteByUsername(user_product.Username);
                break;

            case "Product Id":
                result = db_userproduct.DeleteByProductId(user_product.ProductId);
                break;

            case "Both":
                result = db_userproduct.Delete(user_product);
                break;

            default:
                result = "The chosen instanse to use is invalid.";
                break;
            }

            return(result);
        }
Ejemplo n.º 2
0
        public void Cleanup()
        {
            List <UserProduct> user_products;

            db_userproduct.DeleteByUsername(user.Username);

            foreach (Product product in products)
            {
                user_products = db_userproduct.FindUserProductByProductId(product.Id);

                foreach (UserProduct user_product in user_products)
                {
                    db_userproduct.Delete(user_product);
                }

                db_product.DeleteProduct(product.Id);
            }
        }