Example #1
0
        /// <summary>
        /// Remove line item to the cart.
        /// </summary>
        /// <param name="param"></param>
        /// <returns>The full and updated cart details</returns>
        public virtual Task <ProcessedCart> RemoveLineItemAsync(RemoveLineItemParam 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 (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.CartName)), nameof(param));
            }
            if (param.LineItemId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.LineItemId)), nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }

            var request = new RemoveLineItemRequest
            {
                ScopeId     = param.Scope,
                CultureName = param.CultureInfo.Name,
                CartName    = param.CartName,
                CartType    = param.CartType,
                Id          = param.LineItemId,
                CustomerId  = param.CustomerId
            };

            var cacheKey = BuildCartCacheKey(param.Scope, param.CustomerId, param.CartName);

            return(CacheProvider.ExecuteAndSetAsync(cacheKey, () => OvertureClient.SendAsync(request)));
        }
Example #2
0
        public virtual async Task <ProcessedCart> RemoveLineItemAsync(RemoveLineItemParam 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 (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException("param.CartName is required", "param");
            }
            if (param.LineItemId == Guid.Empty)
            {
                throw new ArgumentException("param.LineItemId is required", "param");
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException("param.CustomerId is required", "param");
            }

            var request = new RemoveLineItemRequest
            {
                ScopeId     = param.Scope,
                CultureName = param.CultureInfo.Name,
                CartName    = param.CartName,
                Id          = param.LineItemId,
                CustomerId  = param.CustomerId
            };

            var cacheKey = BuildWishListCacheKey(param.Scope, param.CustomerId, param.CartName);

            return(await CacheProvider.ExecuteAndSetAsync(cacheKey, () => OvertureClient.SendAsync(request)).ConfigureAwait(false));
        }