/// <summary>
        /// finds a list of user products by username, productId or both.
        /// </summary>
        /// <param name="user_product"></param>
        /// <param name="instance_use"></param>
        /// <returns>List<UserProduct></returns>
        public List <UserProduct> Find(UserProduct user_product, string instance_use)
        {
            List <UserProduct> result;

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

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

            case "Both":
                result = new List <UserProduct>();
                result.Add(db_userproduct.FindUserProduct(user_product));
                break;

            default:
                result = new List <UserProduct>();
                break;
            }

            return(result);
        }
Пример #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);
            }
        }