Ejemplo n.º 1
0
        public ActionResult Index([Bind(Prefix = "Form")]CartForm form)
        {
            // apply form
            var cookieItems = new List<CookieCartItem>();
            foreach (var formItem in form.CartItems)
            {
                var cookieItem = new CookieCartItem
                                 {
                                     VariantId = formItem.VariantId,
                                     Quantity = formItem.Quantity
                                 };
                cookieItems.Add(cookieItem);
            }

            SaveCookieCart(cookieItems);

            return RedirectToAction("Index");
        }
Ejemplo n.º 2
0
        public ActionResult Index([Bind(Prefix = "Form")] CartForm form)
        {
            // apply form
            var cookieItems = new List <CookieCartItem>();

            foreach (var formItem in form.CartItems)
            {
                var cookieItem = new CookieCartItem
                {
                    VariantId = formItem.VariantId,
                    Quantity  = formItem.Quantity
                };
                cookieItems.Add(cookieItem);
            }

            SaveCookieCart(cookieItems);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        protected List<CookieCartItem> GetCookieCart()
        {
            var cartItems = new List<CookieCartItem>();

            var cookie = Request.Cookies[CartCookieName];
            if (cookie != null && cookie.Value.Length > 0)
            {
                foreach (string value in cookie.Value.Split(','))
                {
                    var values = value.Split('|');
                    var item = new CookieCartItem
                               {
                                   VariantId = int.Parse(values[0]),
                                   Quantity = int.Parse(values[1])
                               };

                    cartItems.Add(item);
                }
            }

            return cartItems;
        }
Ejemplo n.º 4
0
        protected List <CookieCartItem> GetCookieCart()
        {
            var cartItems = new List <CookieCartItem>();

            var cookie = Request.Cookies[CartCookieName];

            if (cookie != null && cookie.Value.Length > 0)
            {
                foreach (string value in cookie.Value.Split(','))
                {
                    var values = value.Split('|');
                    var item   = new CookieCartItem
                    {
                        VariantId = int.Parse(values[0]),
                        Quantity  = int.Parse(values[1])
                    };

                    cartItems.Add(item);
                }
            }

            return(cartItems);
        }