Пример #1
0
        private void QtyOp(ref CartVM model, QtyOps op)
        {
            switch (op)
            {
            case QtyOps.Increment:
                model.Quantity++;
                break;

            case QtyOps.Decrement:
                model.Quantity--;
                break;

            default:
                break;
            }
        }
Пример #2
0
        private JsonResult ChangeProductQty(int productId, QtyOps op)
        {
            List <CartVM> cart = Cart;

            using (DB db = new DB())
            {
                CartVM model = cart.FirstOrDefault(x => x.ProductId == productId);
                QtyOp(ref model, op);
                if (op == QtyOps.Decrement && model.Quantity == 0)
                {
                    cart.Remove(model);
                }
                var result = new { qty = model.Quantity, price = model.Price };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }