Exemple #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);
        }
Exemple #2
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);
        }