示例#1
0
        public virtual async Task <IHttpActionResult> AddLineItem(AddLineItemViewModel request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            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
            });

            return(Ok(vm));
        }