/// <summary> /// Gets the loyalty card status including the loyalty groups and the reward points status. /// </summary> /// <param name="request">The request containing the card number.</param> /// <returns>The response containing the loyalty card status.</returns> private static GetLoyaltyCardStatusServiceResponse GetLoyaltyCardStatus(GetLoyaltyCardStatusServiceRequest request) { // Get loyalty card basic information var getLoyaltyCardDataRequest = new GetLoyaltyCardDataRequest(request.LoyaltyCardNumber); LoyaltyCard loyaltyCard = request.RequestContext.Execute <SingleEntityDataServiceResponse <LoyaltyCard> >(getLoyaltyCardDataRequest).Entity; if (loyaltyCard == null) { return(new GetLoyaltyCardStatusServiceResponse()); } var validateCustomerAccountRequest = new GetValidatedCustomerAccountNumberServiceRequest(loyaltyCard.CustomerAccount, throwOnValidationFailure: true); request.RequestContext.Execute <GetValidatedCustomerAccountNumberServiceResponse>(validateCustomerAccountRequest); // Get loyalty groups and loyalty tiers DateTimeOffset channelDateTime = request.RequestContext.GetNowInChannelTimeZone(); var getLoyaltyGroupsAndTiersDataRequest = new GetLoyaltyGroupsAndTiersDataRequest(request.LoyaltyCardNumber, request.RetrieveRewardPointStatus); getLoyaltyGroupsAndTiersDataRequest.QueryResultSettings = QueryResultSettings.AllRecords; loyaltyCard.LoyaltyGroups = request.RequestContext.Execute <EntityDataServiceResponse <LoyaltyGroup> >(getLoyaltyGroupsAndTiersDataRequest).PagedEntityCollection.Results; // Get reward points status if (request.RetrieveRewardPointStatus) { var serviceRequest = new GetLoyaltyCardRewardPointsStatusRealtimeRequest( channelDateTime, request.LoyaltyCardNumber, excludeBlocked: false, excludeNoTender: false, includeRelatedCardsForContactTender: false, includeNonRedeemablePoints: false, includeActivePointsOnly: false); EntityDataServiceResponse <LoyaltyCard> serviceResponse = request.RequestContext.Execute <EntityDataServiceResponse <LoyaltyCard> >(serviceRequest); LoyaltyCard loyaltyCardWithPoints = serviceResponse.PagedEntityCollection.FirstOrDefault(); if (loyaltyCardWithPoints != null) { loyaltyCard.RewardPoints = loyaltyCardWithPoints.RewardPoints; } } var response = new GetLoyaltyCardStatusServiceResponse(loyaltyCard); return(response); }
/// <summary> /// Gets loyalty card reward points status from AX. /// </summary> /// <param name="request">The get loyalty card reward points status request.</param> /// <returns>The get loyalty card reward points status response.</returns> private static EntityDataServiceResponse <LoyaltyCard> GetLoyaltyCardRewardPointsStatus(GetLoyaltyCardRewardPointsStatusRealtimeRequest request) { var transactionService = new TransactionService.TransactionServiceClient(request.RequestContext); Collection <LoyaltyCard> cardsStatus = transactionService.GetLoyaltyCardRewardPointsStatus( request.ChannelLocalDate, request.LoyaltyCardNumber, request.ExcludeBlocked, request.ExcludeNoTender, request.IncludeRelatedCardsForContactTender, request.IncludeNonRedeemablePoints, request.IncludeActivePointsOnly, request.RequestContext.LanguageId); return(new EntityDataServiceResponse <LoyaltyCard>(cardsStatus.AsPagedResult())); }