/// <summary> /// Associates the loyalty card with current cart. /// </summary> /// <param name="storefront">The storefront.</param> /// <param name="visitorContext">The visitor context.</param> /// <param name="loyaltyCardNumber">The loyalty card number.</param> /// <returns> /// The manager response where the result is returned indicating the success or failure of the operation. /// </returns> public virtual ManagerResponse <UpdateLoyaltyCardIdResult, bool> AssociateLoyaltyCardWithCurrentCart([NotNull] CommerceStorefront storefront, string userId, string loyaltyCardNumber) { Assert.ArgumentNotNull(storefront, "storefront"); Assert.ArgumentNotNullOrEmpty(loyaltyCardNumber, "loyaltyCardNumber"); var result = new UpdateLoyaltyCardIdResult { Success = false }; var cartResult = this.CartManager.GetCart(userId); if (!cartResult.ServiceProviderResult.Success || cartResult.Result == null) { result.SystemMessages.ToList().AddRange(cartResult.ServiceProviderResult.SystemMessages); return(new ManagerResponse <UpdateLoyaltyCardIdResult, bool>(result, result.Success)); } var cart = cartResult.ServiceProviderResult.Cart; var request = new UpdateLoyaltyCardIdRequest(userId, loyaltyCardNumber, cart.ExternalId); result = this.LoyaltyProgramServiceProvider.UpdateLoyaltyCardId(request); result.WriteToSitecoreLog(); return(new ManagerResponse <UpdateLoyaltyCardIdResult, bool>(result, result.Success)); }
/// <summary> /// Associates the loyalty card with current cart. /// </summary> /// <param name="storefront">The storefront.</param> /// <param name="visitorContext">The visitor context.</param> /// <param name="loyaltyCardNumber">The loyalty card number.</param> /// <returns> /// The manager response where the result is returned indicating the success or failure of the operation. /// </returns> public virtual ManagerResponse<UpdateLoyaltyCardIdResult, bool> AssociateLoyaltyCardWithCurrentCart([NotNull] CommerceStorefront storefront, [NotNull] VisitorContext visitorContext, string loyaltyCardNumber) { Assert.ArgumentNotNull(storefront, "storefront"); Assert.ArgumentNotNull(visitorContext, "visitorContext"); Assert.ArgumentNotNullOrEmpty(loyaltyCardNumber, "loyaltyCardNumber"); var result = new UpdateLoyaltyCardIdResult { Success = false }; var cartResult = this.CartManager.GetCurrentCart(storefront, visitorContext); if (!cartResult.ServiceProviderResult.Success || cartResult.Result == null) { result.SystemMessages.ToList().AddRange(cartResult.ServiceProviderResult.SystemMessages); return new ManagerResponse<UpdateLoyaltyCardIdResult, bool>(result, result.Success); } var cart = cartResult.ServiceProviderResult.Cart; var request = new UpdateLoyaltyCardIdRequest(visitorContext.UserId, loyaltyCardNumber, cart.ExternalId); result = this.LoyaltyProgramServiceProvider.UpdateLoyaltyCardId(request); Helpers.LogSystemMessages(result.SystemMessages, result); return new ManagerResponse<UpdateLoyaltyCardIdResult, bool>(result, result.Success); }