Exemplo n.º 1
0
 public ActionResult AddProduct()
 {
     //create an empty product
     Product product = new Product();
        //products.Add(product);
     return View(product);
 }
 public ActionResult AddProduct()
 {
     Product product = new Product()
     {
         Id = IdCount,
         Name = "",
         Foto = "https://cdn2.iconfinder.com/data/icons/freecns-cumulus/16/519660-164_QuestionMark-512.png",
         Price = (decimal)0
     };
     IdCount++;
     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;
                }
            }
            return View(product);
        }
        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 SaveProduct(Product product)
 {
     db.Products.Add(product);
     db.SaveChanges();
     return View(product);
 }
 public ActionResult NewProduct(Product product)
 {
     return View(product);
 }
 public ActionResult Editlenmis(Product product)
 {
     db.Products.Add(product);
     db.SaveChanges();
     return View(product);
 }
Exemplo n.º 8
0
 public ActionResult SaveProduct(Product product)
 {
     products.Add(product);
     return View(product);
 }
Exemplo n.º 9
0
        public ActionResult ProductListofEachCart(int id)
        {
            List<Product> productsofeachcart = new List<Product>();
            Product product = new Product();
            foreach (var find in products)
            {

                if (find.CartId == id)
                {

                    product.Name = find.Name;
                    product.Price = find.Price;
                    product.Id = find.Id;

                    productsofeachcart.Add(product);

                }

            }
            return View(productsofeachcart);
        }
Exemplo n.º 10
0
        public ActionResult EditProduct(string name)
        {
            //   products.Add(product);
                 ViewBag.Message = "Your application description page.";
                   Product product = new Product();

                    foreach (var find in products)
                    {

                        if (find.Name == name)
                        {

                            product.Name = find.Name;
                            product.Price = find.Price;
                            product.Id = find.Id;

                    products.Remove(find);
                    break;
                        }

                    }
                     return View(product);
        }
Exemplo n.º 11
0
 public ActionResult SaveProduct(Product product)
 {
     ViewBag.Message = "SaveProduct worked !";
     products.Add(product);
     return View(product);
 }
Exemplo n.º 12
0
        public ActionResult SaveModifiedProduct(Product product)
        {
            // This search will be far less ugly when we'll have a db
            foreach (Product p in HomeController.products)
                if (p.Id == product.Id)
                {
                    p.Name = product.Name;
                    p.Price = product.Price;
                    p.Foto = product.Foto;
                    return View("SaveProduct", p);
                }

            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        }