public ActionResult AddProduct()
        {
            Product product = new Product();
            product.Name = "";
            product.Price = (decimal)0;

            return View(product);
        }
Beispiel #2
0
 public ActionResult AddProduct()
 {
     Product product = new Product()
     {
         Name = "",
         Price = (decimal)0
     };
     return View(product);
 }
        public ActionResult AddtoCart(int Id)
        {
            Product product = new Product();

            foreach (var p in db.Products)
            {
                if (p.Id == Id)
                {
                    product.Name = p.Name;
                    product.Id = p.Id;
                    product.Price = p.Price;
                    CartProducts.Add(p);
                }
            }
            return View(product);
        }
        public ActionResult Index()
        {
            Product product1 = new Product();
            product1.Id = 1;
            product1.Name = "Erikli 19L";
            product1.Price = (decimal)7.90;

            Product product2 = new Product();
            product2.Id = 2;
            product2.Name = "Erikli 15L";
            product2.Price = (decimal)6.90;

            List<Product> products = new List<Product>();
            products.Add(product1);
            products.Add(product2);

            return View();
        }
        public ActionResult EditProduct(int Id)
        {
            Product product = new Product();
            foreach (Product p in db.Products)
            {
                if (p.Id == Id)
                {
                    product.Name = p.Name;
                    product.Price = p.Price;
                    product.Id = p.Id;

                    db.Products.Remove(p);
                    break;
                }
            }
            db.SaveChanges();
            return View(product);
        }
Beispiel #6
0
        public ActionResult AddToCart(string Name)
        {
            // TODO find product from this.products
            Product product = new Product(); // lıstenın ıcınde buldugumuz product

            // sepete ekleme işlemi
            foreach (var p in products)
            {
                if (p.Name == Name)
                {
                    product.Name = p.Name;
                    product.Price = p.Price;
                    product.Id = p.Id;
                    cartproducts.Add(p);
                    break;
                }
              }

            return View(product); //sepete eklenmistir goruntusu.
        }
Beispiel #7
0
 public ActionResult Buy()
 {
     Cart cart = new Cart();
     cart.TotalPrice = 0;
     cart.cartproducts = new List<Product>();
     cart.Id = i;
     cart.UserId = 1;
     Product product = new Product();
     foreach (Product p in cartproducts)
     {
         product.Id = p.Id;
         product.Name = p.Name;
         product.Price = p.Price;
         cart.cartproducts.Add(product);
         cart.TotalPrice += p.Price;
         i++;
     }
     return View(cart);
 }
Beispiel #8
0
 public ActionResult SaveProduct(Product product)
 {
     products.Add(product);
     return View(product);
 }
Beispiel #9
0
        public ActionResult EditProduct(string Name)
        {
            Product product = new Product();
            foreach (Product p in products)
            {
                if (p.Name == Name)
                {
                    product.Name = p.Name;
                    product.Price = p.Price;
                    product.Id = p.Id;

                    products.Remove(p);
                    break;
                }
            }
            return View(product);
        }
        public ActionResult ProductEdited(Product product)
        {
            db.Products.Add(product);
            db.SaveChanges();

            return View(product);
        }
 public ActionResult AddProduct(Product product)
 {
     return View(product);
 }