コード例 #1
0
        // GET: Cart
        public ActionResult Index(string id)
        {
            vegetableModel vegetableModel = new vegetableModel();

            ViewBag.vegetables = vegetableModel.findAll();
            return(View());
        }
コード例 #2
0
        public ActionResult Buy(string id)
        {
            vegetableModel vegetableModel = new vegetableModel();

            if (Session["cart"] == null)
            {
                List <Item> cart = new List <Item>();
                cart.Add(new Item {
                    Vegetable = vegetableModel.find(id), Quantity = 1
                });
                Session["cart"] = cart;
            }
            else
            {
                List <Item> cart  = (List <Item>)Session["cart"];
                int         index = isExist(id);
                if (index != -1)
                {
                    cart[index].Quantity++;
                }
                else
                {
                    cart.Add(new Item {
                        Vegetable = vegetableModel.find(id), Quantity = 1
                    });
                }
                Session["cart"] = cart;
            }
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        // GET: Vegetable
        public ActionResult Vegetable()
        {
            vegetableModel vegetableModel = new vegetableModel();

            ViewBag.vegetables = vegetableModel.findAll();
            return(View());
        }