Exemplo n.º 1
0
        public ActionResult RemoveCartItem(int id)
        {
            PhongKhachSan _Phong = new PhongKhachSanF().FindEnity(id);
            Cart          _Cart  = (Cart)Session["CartSession"];

            if (_Cart != null)
            {
                _Cart.RemoveItem(_Phong);
                Session["CartSession"] = _Cart;
            }
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 2
0
        public JsonResult DatPhong(List <CartAjax> listCart)
        {
            Cart Cart = new Cart();

            foreach (CartAjax item in listCart)
            {
                PhongKhachSan phong = new PhongKhachSanF().FindEnity(item.id);
                Cart.AddItem(phong, item.quantity);
            }
            Session["CartSession"] = Cart;
            return(Json(new { status = 200, data = "oke" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult UpdateCart(int id, FormCollection f)
        {
            PhongKhachSan _Phong      = new PhongKhachSanF().FindEnity(id);
            Cart          _Cart       = (Cart)Session["CartSession"];
            int           NewQuantity = int.Parse(f["txtQuantity"].ToString());

            if (_Cart == null)
            {
                _Cart.UpdateItem(_Phong, NewQuantity);
                Session["CartSession"] = _Cart;
            }
            else
            {
                _Cart = new Cart();
                _Cart.AddItem(_Phong, NewQuantity);
            }
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 4
0
        public ActionResult AddItem(int id, string returnURL, FormCollection f)
        {
            PhongKhachSan _Phong  = new PhongKhachSanF().FindEnity(id);
            Cart          _Cart   = (Cart)Session["CartSession"];
            int           Quantiy = int.Parse(f["txtQuantity"].ToString());

            if (_Cart == null)
            {
                _Cart = new Cart();
            }
            _Cart.AddItem(_Phong, Quantiy);
            Session["CartSession"] = _Cart;

            if (string.IsNullOrEmpty(returnURL))
            {
                return(RedirectToAction("Index", "Home"));
            }

            return(Redirect(returnURL));
        }