Пример #1
0
        // GET: Cart/Details/5
        public ActionResult Details(int id)
        {
            ProductDBHandle productModel = new ProductDBHandle();

            productModel.GetProduct();
            if (Session["cart"] == null)
            {
                List <Item> cart = new List <Item>();

                cart.Add(new Item {
                    book = productModel.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 {
                        book = productModel.find(id), Quantity = 1
                    });
                }
                Session["cart"] = cart;
            }
            return(RedirectToAction("Index"));
        }
Пример #2
0
        // GET: Product
        public ActionResult Index()
        {
            ProductDBHandle dbhandle = new ProductDBHandle();

            ModelState.Clear();
            return(View(dbhandle.GetProduct()));
        }
Пример #3
0
        // GET: Product/Details/5
        public ActionResult Details(int id)
        {
            ProductDBHandle sdb = new ProductDBHandle();

            return(View(sdb.GetProduct().Find(smodel => smodel.Id == id)));
        }
Пример #4
0
        // GET: Admin/Edit/5

        public ActionResult Edit(int id)
        {
            ProductDBHandle pdb = new ProductDBHandle();

            return(View(pdb.GetProduct().Find(bmodel => bmodel.Id == id)));
        }