Example #1
0
 /*
  * Description: Deletes a product in the database
  * Parameter: usernameToDelete
  * return: bool
  */
 public static bool deleteProduct(string productToDelete, string username)
 {
     foreach (Product product in registeredProducts)
     {
         if (product.seller.Equals(username))
         {
             if (product.pName.Equals(productToDelete))
             {
                 registeredProducts.Remove(product);
                 JsonManager.saveProduct(registeredProducts);
                 return(true);
             }
         }
     }
     return(false);
 }
Example #2
0
        /*
         * Description: Deletes all product from a seller in the database
         * Parameter: username
         * return: bool
         */
        public static bool deleteProduct(string username)
        {
            var index = registeredProducts.First;

            while (index != null)
            {
                var nextIndex = index.Next;
                if (index.Value.seller.Equals(username))
                {
                    registeredProducts.Remove(index);
                }
                index = nextIndex;
            }
            JsonManager.saveProduct(registeredProducts);
            return(true);
        }
Example #3
0
 /*
  * Description: Registers a product in the database
  * Parameters: newProduct-> product being registered
  * Return: None
  */
 public static void registerProduct(Product newProduct)
 {
     registeredProducts.AddLast(newProduct);
     JsonManager.saveProduct(registeredProducts);
 }