public async Task <IActionResult> SetCartLineProperties([FromBody] ODataActionParameters value)
        {
            if (!this.ModelState.IsValid)
            {
                return((IActionResult) new BadRequestObjectResult(this.ModelState));
            }

            if (!value.ContainsKey(Constants.Settings.CartId))
            {
                return((IActionResult) new BadRequestObjectResult((object)value));
            }
            var id = value[Constants.Settings.CartId];

            if (string.IsNullOrEmpty(id?.ToString()))
            {
                return((IActionResult) new BadRequestObjectResult((object)value));
            }

            var cartId = id.ToString();

            var cartLineProperties = new CartLineProperties();

            if (value.ContainsKey(Constants.Settings.CartLineProperties))
            {
                var cartlinePropObj = value[Constants.Settings.CartLineProperties];

                if (!string.IsNullOrEmpty(cartLineProperties?.ToString()))
                {
                    cartLineProperties = JsonConvert.DeserializeObject <CartLineProperties>(cartlinePropObj.ToString());
                }
            }

            var command = this.Command <SetCartLinePropertiesCommand>();
            await Task.Delay(1);

            var runCommand = await command.Process(this.CurrentContext, cartId, cartLineProperties, $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}");

            return((IActionResult) new ObjectResult((object)runCommand));
        }
        public async Task <Cart> Process(CommerceContext commerceContext, string cartId, CartLineProperties lineProperties, string baseUrl)
        {
            try
            {
                var cart = GetCart(cartId, commerceContext, baseUrl);
                if (cart == null)
                {
                    return(null);
                }


                // Set the custom fields on the cartlines
                if (cart.Lines != null && cart.Lines.Any() && lineProperties != null &&
                    lineProperties.CartLineProperty.Any())
                {
                    foreach (var cartLineProperty in lineProperties.CartLineProperty)
                    {
                        var cartLineComponent = cart.Lines.FirstOrDefault(x => x.Id == cartLineProperty.CartLineId);
                        if (cartLineComponent != null)
                        {
                            cartLineComponent
                            .GetComponent <CartComponent>().Properties = cartLineProperty.Properties;
                        }
                    }
                }

                var result = await this._persistEntityPipeline.Run(new PersistEntityArgument(cart), commerceContext.GetPipelineContextOptions());

                return(result.Entity as Cart);
            }
            catch (Exception e)
            {
                return(await Task.FromException <Cart>(e));
            }
        }