private AddCouponRequest MapParamToRequest(CouponParam parameters) { var request = new AddCouponRequest() { CartName = parameters.CartName, CouponCode = parameters.CouponCode, CultureName = parameters.CultureInfo.Name, CustomerId = parameters.CustomerId, ScopeId = parameters.Scope, }; return(request); }
internal static ProcessedCart CreateCartBasedOnAddCouponRequest(AddCouponRequest request, CouponState state) { var cart = new ProcessedCart { Name = request.CartName, CultureName = request.CultureName, Coupons = new List<Coupon>() { new Coupon() { CouponCode = request.CouponCode, CouponState = state } }, CustomerId = request.CustomerId, ScopeId = request.ScopeId, Shipments = new List<Shipment>() }; return cart; }
/// <summary> /// Adds a coupon to the Cart, then returns an instance of the cart. /// </summary> /// <param name="param"></param> /// <returns>The full and updated cart details.</returns> public virtual Task <ProcessedCart> AddCouponAsync(CouponParam param) { if (param == null) { throw new ArgumentNullException("param"); } if (string.IsNullOrWhiteSpace(param.Scope)) { throw new ArgumentException("Scope may not be null or whitespace.", "param"); } if (param.CustomerId == Guid.Empty) { throw new ArgumentException("CustomerId may not be Empty", "param"); } if (string.IsNullOrWhiteSpace(param.CartName)) { throw new ArgumentException("CartName may not be null or whitespace.", "param"); } if (param.CultureInfo == null) { throw new ArgumentNullException("param", "CultureInfo cannot be null."); } if (string.IsNullOrWhiteSpace(param.CouponCode)) { throw new ArgumentException("CouponCode may not be null or whitespace", "param"); } var request = new AddCouponRequest { CartName = param.CartName, CouponCode = param.CouponCode, CultureName = param.CultureInfo.Name, CustomerId = param.CustomerId, ScopeId = param.Scope }; var cacheKey = BuildCartCacheKey(param.Scope, param.CustomerId, param.CartName); return(CacheProvider.ExecuteAndSetAsync(cacheKey, () => OvertureClient.SendAsync(request))); }
/// <summary> /// Adds a coupon to the Cart, then returns an instance of the cart. /// </summary> /// <param name="param"></param> /// <returns>The full and updated cart details.</returns> public virtual Task <ProcessedCart> AddCouponAsync(CouponParam 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.CustomerId == Guid.Empty) { throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param)); } if (string.IsNullOrWhiteSpace(param.CartName)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.CartName)), nameof(param)); } if (param.CultureInfo == null) { throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param)); } if (string.IsNullOrWhiteSpace(param.CouponCode)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.CouponCode)), nameof(param)); } var request = new AddCouponRequest { CartName = param.CartName, CouponCode = param.CouponCode, CultureName = param.CultureInfo.Name, CustomerId = param.CustomerId, ScopeId = param.Scope }; var cacheKey = BuildCartCacheKey(param.Scope, param.CustomerId, param.CartName); return(CacheProvider.ExecuteAndSetAsync(cacheKey, () => OvertureClient.SendAsync(request))); }