Example #1
0
        public ActionResult Cart(string SessionId, string Id, string cmd)
        {
            if (!Util.SessionExist(SessionId))
            {
                return(RedirectToAction("Login", "Login"));
            }

            if (Id != null)
            {
                Product  product = Util.GetProductById(int.Parse(Id));
                CartItem item    = product.ConvertToCartItem();
                TempCart Cart    = (TempCart)Session[SessionId];
                if (cmd == "minus")
                {
                    Cart.Minus(item);
                }
                else if (cmd == "plus")
                {
                    Cart.Add(item);
                }
                Session[SessionId] = Cart;
            }
            ViewData["SessionId"] = SessionId;
            return(View());
        }
Example #2
0
        public ActionResult Gallery(string SessionId, string Id, string Search)
        {
            //Check whether sessionexist. If not, throw user back
            if (!Util.SessionExist(SessionId))
            {
                return(RedirectToAction("Login", "Login"));
            }

            //if there is Id, User requested add the product into the cart
            if (Id != null)
            {
                // add to shopping cart
                TempCart Cart    = (TempCart)Session[SessionId];
                Product  product = Util.GetProductById(int.Parse(Id));
                CartItem item    = product.ConvertToCartItem();
                Cart.Add(item);
                Session[SessionId] = Cart;
            }

            //get products dependant on search
            List <Product> products = new List <Product>();

            if (Search == null || Search == "")
            {
                products = Util.GetProducts();
            }
            else
            {
                products = Util.GetProducts(Search);
            }

            //pass to view for view use
            ViewData["Products"]  = products;
            ViewData["SessionId"] = SessionId;
            ViewData["Username"]  = Util.GetCustomerBySessionId(SessionId).Username;
            ViewData["Search"]    = Search;
            return(View());
        }