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); }
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); }