예제 #1
0
        public virtual async Task <IHttpActionResult> AddLineItem(AddLineItemViewModel request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (!ComposerContext.IsAuthenticated)
            {
                return(BadRequest("Authorization required"));
            }

            var vm = await WishListViewService.AddLineItemAsync(new AddLineItemParam
            {
                Scope       = ComposerContext.Scope,
                CultureInfo = ComposerContext.CultureInfo,
                CustomerId  = ComposerContext.CustomerId,
                CartName    = CartConfiguration.WishlistCartName,
                ProductId   = request.ProductId,
                VariantId   = request.VariantId,
                Quantity    = request.Quantity.GetValueOrDefault(),
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),
                RecurringOrderFrequencyName = request.RecurringOrderFrequencyName,
                RecurringOrderProgramName   = request.RecurringOrderProgramName
            });

            return(Ok(vm));
        }
예제 #2
0
        public virtual async Task <IHttpActionResult> AddLineItem(AddLineItemViewModel request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var checkoutUrl = GetCheckoutUrl();
            var homepageUrl = GetHomepageUrl();

            var vm = await CartService.AddLineItemAsync(new AddLineItemParam
            {
                Scope       = ComposerContext.Scope,
                CultureInfo = ComposerContext.CultureInfo,
                CustomerId  = ComposerContext.CustomerId,
                CartName    = CartConfiguration.ShoppingCartName,
                ProductId   = request.ProductId,
                VariantId   = request.VariantId,
                Quantity    = request.Quantity.GetValueOrDefault(),
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),
                RecurringOrderFrequencyName = request.RecurringOrderFrequencyName,
                RecurringOrderProgramName   = request.RecurringOrderProgramName
            });

            SetCheckoutUrl(vm, checkoutUrl);
            SetHomepageUrl(vm, homepageUrl);
            SetEditCartUrl(vm);

            return(Ok(vm));
        }