public bool AddProduct(Product prod) { if (IsValidProduct(prod)) { _productControl.AddProduct(prod); return(true); } else { return(false); } }
private void AddBtn_Click(object sender, RoutedEventArgs e) { Brand selectedBrand = (Brand)BrandCombo.SelectedItem; Category selectedCategory = (Category)CategoryCombo.SelectedItem; if (CheckForInput()) { Product product = new Product { Name = NameTxt.Text, Price = Convert.ToDecimal(PriceTxt.Text), Description = DescriptionTxt.Text, AmountOnStock = Convert.ToInt32(AmountOnStockTxt.Text), BrandId = selectedBrand.BrandId, CategoryId = selectedCategory.CategoryId }; productControl.AddProduct(product); MessageBox.Show(product.Name + " Successfully added to database"); } else { MessageBox.Show("Please fill out all the text fields"); } }