Ejemplo n.º 1
0
        public ActionResult Create(ProductViewModel model)
        {
            try
            {
                ProductBusiness business = new ProductBusiness();

                Product product = new Product()
                {
                    Name        = model.Name,
                    Description = model.Description
                };

                business.Add(product);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
        private void buttonAddProds_Click(object sender, EventArgs e)
        {
            Product product = new Product();

            product.Name       = textBoxProdName.Text;
            product.ImgAddress = textBoxProdImage.Text;
            product.Price      = Convert.ToDecimal(textBoxProdPrice.Text);
            product.Info       = textBoxProdInfo.Text;
            product.Rating     = Convert.ToDouble(textBoxProdRating.Text);

            int selectedCategoryId = (int)comboBoxShowCats.SelectedValue;

            selectedCategory   = categoryBusiness.GetCategoryById(selectedCategoryId);
            product.CategoryId = selectedCategory.Id;

            productBusiness.Add(product);

            MessageBox.Show("Ürün başarıyla eklendi!");

            showProducts.ShowProducts(dataGridViewShowProds);
        }