Exemplo n.º 1
0
        //[HttpPost]
        public ActionResult AddProduct()
        {
            Product product = new Product()
            {
                Name = "",
                Price = (decimal)0
            };

            return View(product);
        }
        public ActionResult AddCart(string Name)
        {
            Product product = new Product();

            foreach (var p in db.Products)
            {
                if (p.Name == Name)
                {
                    product.Name = p.Name;
                    product.Id = p.Id;
                    product.Price = p.Price;
                    CartProducts.Add(p);
                    break;
                }
            }
            db.SaveChanges();
            return View(product);
        }
Exemplo n.º 3
0
 public ActionResult SaveProduct(Product product)
 {
     ViewBag.Message = "SaveProduct worked sir...";
     products.Add(product);
     return View(product);
 }
        // GET: Products/Edit/5
        public ActionResult Edit(string Name)
        {
            Product product = new Product();

            foreach (Product p in db.Products)
            {

                if (p.Name == Name)
                {
                    product.Name = p.Name;
                    product.Price = p.Price;
                    product.Id = p.Id;

                    db.Products.Remove(p);
                    break;
                }

            }
            db.SaveChanges();
            return View(product);
        }
 public ActionResult AddProduct(Product product)
 {
     return View(product);
 }
 public ActionResult SaveProduct(Product product)
 {
     db.Products.Add(product);
     db.SaveChanges();
     return View(product);
 }