Esempio n. 1
0
        public virtual ActionResult AddtoBasket(BasketAddModel model)
        {
            var basketModel = new BasketAddModel
            {
                BasketId                = Sanitizer.GetSafeHtmlFragment(model.BasketId),
                DisplayOrder            = model.DisplayOrder,
                ProductId               = Sanitizer.GetSafeHtmlFragment(model.ProductId),
                Qty                     = model.Qty,
                ItemType                = model.ItemType,
                SubscriptionPlanId      = Sanitizer.GetSafeHtmlFragment(model.SubscriptionPlanId),
                PostCode                = model.PostCode,
                SubscriptionTermId      = Sanitizer.GetSafeHtmlFragment(model.SubscriptionTermId),
                UserSubscriptionPricing = model.UserSubscriptionPricing
            };

            if (basketModel.Qty > 0)
            {
                var resp = ValidateBasket(basketModel.BasketId, basketModel.ProductId, basketModel.Qty);
                if (resp)
                {
                    var basketData = _basketApi.AddToBasket(basketModel);
                    return(JsonSuccess(basketData, JsonRequestBehavior.AllowGet));
                }
                return(JsonSuccess(false, JsonRequestBehavior.AllowGet));
            }
            var basket = _basketApi.AddToBasket(basketModel);

            return(JsonSuccess(basket, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public ActionResult AddtoBasket(BasketAddModel model)
        {
            var basketModel = new BasketAddModel
            {
                BasketId       = Sanitizer.GetSafeHtmlFragment(model.BasketId),
                DisplayOrder   = model.DisplayOrder,
                ProductId      = Sanitizer.GetSafeHtmlFragment(model.ProductId),
                Qty            = model.Qty,
                ItemType       = model.ItemType,
                SubscriptionId = Sanitizer.GetSafeHtmlFragment(model.SubscriptionId),
                PostCode       = model.PostCode
            };
            var basket = _basketApi.AddToBasket(basketModel);

            SiteUtils.SetBasketAction(basket?.Result.Id);
            return(JsonSuccess(basket?.Result, JsonRequestBehavior.AllowGet));
        }