コード例 #1
0
        public void AddNewProduct(string name, Category category, string price)
        { // ENKEL BINNEN DE ACCOLADES VAN DEZE METHODE MOGEN AANPASSINGEN GEBEUREN
            decimal.TryParse(price, out decimal convertedPrice);

            Product newProduct = new Product(name, category, convertedPrice);

            ProductsInShop.Add(newProduct);
        }
コード例 #2
0
        public void DeleteProduct(Product productToDelete)
        {
            if (productToDelete == null)
            {
                throw new Exception(NoProductSelectedToDeleteMessage);
            }

            ProductsInShop.Remove(productToDelete);
        }
コード例 #3
0
        public void AddNewProduct(string name, Category category, string price)
        {
            if (name == "" || category == null || price == "")
            {
                throw new Exception(AllFieldsAreRequiredMessage);
            }

            decimal.TryParse(price, out decimal convertedPrice);

            if (convertedPrice <= 0 || convertedPrice > MaximumPriceOfProduct)
            {
                throw new Exception(NewProductPriceIsWrongMessage);
            }

            Product newProduct = new Product(name, category, convertedPrice);

            ProductsInShop.Add(newProduct);
        }
コード例 #4
0
 public void DeleteProduct(Product productToDelete)
 {// ENKEL BINNEN DE ACCOLADES VAN DEZE METHODE MOGEN AANPASSINGEN GEBEUREN
     ProductsInShop.Remove(productToDelete);
 }