Beispiel #1
0
        /// <summary>
        /// Retrieves the list of carts belonging to a customer
        ///
        /// param.IncludeChildScopes is optional
        /// A value indicating whether to include carts found in child scopes.
        /// </summary>
        /// <param name="param"></param>
        /// <returns>List of Cart Summaries</returns>
        public virtual Task <List <CartSummary> > GetCartsByCustomerIdAsync(GetCartsByCustomerIdParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param", "param is required");
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException("param.Scope is required", "param");
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException("param.CultureInfo is required", "param");
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException("param.CustomerId is required", "param");
            }

            var request = new GetCartsByCustomerIdRequest
            {
                CultureName        = param.CultureInfo.Name,
                CustomerId         = param.CustomerId,
                ScopeId            = param.Scope,
                IncludeChildScopes = param.IncludeChildScopes,
            };

            return(OvertureClient.SendAsync(request));
        }
        /// <summary>
        /// Retrieves the list of carts belonging to a customer
        ///
        /// param.IncludeChildScopes is optional
        /// A value indicating whether to include carts found in child scopes.
        /// </summary>
        /// <param name="param"></param>
        /// <returns>List of Cart Summaries</returns>
        public virtual Task <List <CartSummary> > GetCartsByCustomerIdAsync(GetCartsByCustomerIdParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }

            var request = new GetCartsByCustomerIdRequest
            {
                CultureName        = param.CultureInfo.Name,
                CustomerId         = param.CustomerId,
                ScopeId            = param.Scope,
                IncludeChildScopes = param.IncludeChildScopes,
                CartType           = param.CartType
            };

            return(OvertureClient.SendAsync(request));
        }
Beispiel #3
0
        public virtual async Task <List <ProcessedCart> > GetRecurringCartsAsync(GetRecurringOrderCartsViewModelParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(nameof(param.CultureInfo));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(nameof(param.CustomerId));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(nameof(param.Scope));
            }

            var request = new GetCartsByCustomerIdRequest()
            {
                CustomerId  = param.CustomerId,
                ScopeId     = param.Scope,
                CultureName = param.CultureInfo.Name,
                CartType    = CartConfiguration.RecurringOrderCartType
            };

            var cartSummaries = await OvertureClient.SendAsync(request).ConfigureAwait(false);

            var resultTasks = cartSummaries.Select(cart =>
            {
                var getCartParam = (new GetCartParam
                {
                    Scope = param.Scope,
                    CultureInfo = param.CultureInfo,
                    CustomerId = param.CustomerId,
                    CartName = cart.Name,
                    BaseUrl = param.BaseUrl,
                    ExecuteWorkflow = true
                });
                return(GetCartAsync(getCartParam));
            });

            var carts = await Task.WhenAll(resultTasks);

            carts.Where(i => i != null);

            return(carts.ToList());
        }