Ejemplo n.º 1
0
        /// <summary>
        /// Initializes the specified reward point.
        /// </summary>
        /// <param name="rewardPoint">The reward point.</param>
        public virtual void Initialize(LoyaltyRewardPoint rewardPoint)
        {
            Assert.ArgumentNotNull(rewardPoint, "rewardPoint");

            this.ActivePoints    = rewardPoint.ActivePoints.ToString(Sitecore.Context.Language.CultureInfo);
            this.CurrencyCode    = rewardPoint.CurrencyCode;
            this.Description     = rewardPoint.Description;
            this.ExpiredPoints   = rewardPoint.ExpiredPoints.ToString(Sitecore.Context.Language.CultureInfo);
            this.IssuedPoints    = rewardPoint.IssuedPoints.ToString(Sitecore.Context.Language.CultureInfo);
            this.RewardPointType = rewardPoint.RewardPointType.Name;
            this.UsedPoints      = rewardPoint.UsedPoints.ToString(Sitecore.Context.Language.CultureInfo);

            var transactions = rewardPoint.GetPropertyValue("Transactions") as List <LoyaltyCardTransaction>;

            if (transactions == null || transactions.Count <= 0)
            {
                return;
            }

            foreach (var transaction in transactions)
            {
                var result = new LoyaltyTransactionItemBaseJsonResult();
                result.Initialize(transaction);
                this.Transactions.Add(result);
            }
        }
        /// <summary>
        /// Initializes the specified reward point.
        /// </summary>
        /// <param name="rewardPoint">The reward point.</param>
        public override void Initialize(LoyaltyRewardPoint rewardPoint)
        {
            base.Initialize(rewardPoint);

            this.RewardPointId = Guid.NewGuid().ToGuidString();
            //((Sitecore.Commerce.Connect.DynamicsRetail.Entities.LoyaltyPrograms.LoyaltyRewardPoint)rewardPoint).RewardPointId;
        }
            /// <summary>
            /// Gets the status of the loyalty reward points by card number or directory party record identifier.
            /// </summary>
            /// <param name="channelLocalDate">The local date of the channel.</param>
            /// <param name="loyaltyCardNumber">The loyalty card number.</param>
            /// <param name="excludeBlocked">
            /// The flag indicating whether to exclude the card status if the card is blocked.
            /// </param>
            /// <param name="excludeNoTender">
            /// The flag indicating whether to exclude the card status if the card is no tender or blocked.
            /// </param>
            /// <param name="includeRelatedCardsForContactTender">
            /// The flag indicating whether to include the status of the related cards if the given card is contact tender.
            /// </param>
            /// <param name="includeNonRedeemablePoints">
            /// The flag indicating whether to include non-redeemable points status in the result.
            /// </param>
            /// <param name="includeActivePointsOnly">
            /// The flag indicating whether to return only the active points; otherwise, returns the status of issued, used and expired points as well.
            /// </param>
            /// <param name="locale">The locale of the translations.</param>
            /// <returns>The loyalty point status per loyalty card.</returns>
            public Collection <LoyaltyCard> GetLoyaltyCardRewardPointsStatus(
                DateTimeOffset channelLocalDate,
                string loyaltyCardNumber,
                bool excludeBlocked,
                bool excludeNoTender,
                bool includeRelatedCardsForContactTender,
                bool includeNonRedeemablePoints,
                bool includeActivePointsOnly,
                string locale)
            {
                string channelLocalDateStr = SerializationHelper.ConvertDateTimeToAXDateString(channelLocalDate.LocalDateTime, 213);
                var    parameters          = new object[]
                {
                    channelLocalDateStr,
                    loyaltyCardNumber,
                    excludeBlocked,
                    excludeNoTender,
                    includeRelatedCardsForContactTender,
                    includeNonRedeemablePoints,
                    includeActivePointsOnly,
                    locale
                };

                var data = this.InvokeMethod(GetLoyaltyCardRewardPointsStatusMethodName, parameters);

                // Translate the result data into a list of loyalty card with reward points status
                string statusXML = (string)data[0];

                XDocument doc  = XDocument.Parse(statusXML);
                XElement  root = doc.Elements("LoyaltyCardRewardPointsStatusList").SingleOrDefault();
                Collection <LoyaltyCard> cards = null;

                if (root != null)
                {
                    var cardStatusList = root.Elements("LoyaltyCardRewardPointsStatus");
                    cards = new Collection <LoyaltyCard>();
                    foreach (var cardStatus in cardStatusList)
                    {
                        var card = new LoyaltyCard();
                        card.CardNumber = TransactionServiceClient.GetAttributeValue(cardStatus, "LoyaltyCardNumber");
                        cards.Add(card);

                        var rewardPointStatusList = cardStatus.Elements("RewardPointStatus");
                        foreach (var rewardPointStatus in rewardPointStatusList)
                        {
                            var rewardPoint = new LoyaltyRewardPoint();
                            rewardPoint.RewardPointId       = TransactionServiceClient.GetAttributeValue(rewardPointStatus, "RewardPointId");
                            rewardPoint.Description         = TransactionServiceClient.GetAttributeValue(rewardPointStatus, "RewardPointDescription");
                            rewardPoint.RewardPointType     = (LoyaltyRewardPointType)Convert.ToInt32(TransactionServiceClient.GetAttributeValue(rewardPointStatus, "RewardPointType"));
                            rewardPoint.RewardPointCurrency = TransactionServiceClient.GetAttributeValue(rewardPointStatus, "Currency");
                            rewardPoint.IsRedeemable        = Convert.ToBoolean(TransactionServiceClient.GetAttributeValue(rewardPointStatus, "Redeemable"));
                            if (rewardPoint.IsRedeemable)
                            {
                                rewardPoint.RedeemRanking = Convert.ToInt32(TransactionServiceClient.GetAttributeValue(rewardPointStatus, "RedeemRanking"));
                            }

                            rewardPoint.IssuedPoints  = Convert.ToDecimal(TransactionServiceClient.GetAttributeValue(rewardPointStatus, "Issued"));
                            rewardPoint.UsedPoints    = Convert.ToDecimal(TransactionServiceClient.GetAttributeValue(rewardPointStatus, "Used"));
                            rewardPoint.ExpiredPoints = Convert.ToDecimal(TransactionServiceClient.GetAttributeValue(rewardPointStatus, "Expired"));
                            rewardPoint.ActivePoints  = Convert.ToDecimal(TransactionServiceClient.GetAttributeValue(rewardPointStatus, "Active"));

                            card.RewardPoints.Add(rewardPoint);
                        }
                    }
                }

                return(cards);
            }
        /// <summary>
        /// Initializes the specified reward point.
        /// </summary>
        /// <param name="rewardPoint">The reward point.</param>
        public virtual void Initialize(LoyaltyRewardPoint rewardPoint)
        {
            Assert.ArgumentNotNull(rewardPoint, "rewardPoint");

            this.ActivePoints = rewardPoint.ActivePoints.ToString(Sitecore.Context.Language.CultureInfo);
            this.CurrencyCode = rewardPoint.CurrencyCode;
            this.Description = rewardPoint.Description;
            this.ExpiredPoints = rewardPoint.ExpiredPoints.ToString(Sitecore.Context.Language.CultureInfo);
            this.IssuedPoints = rewardPoint.IssuedPoints.ToString(Sitecore.Context.Language.CultureInfo);
            this.RewardPointType = rewardPoint.RewardPointType.Name;
            this.UsedPoints = rewardPoint.UsedPoints.ToString(Sitecore.Context.Language.CultureInfo);

            var transactions = rewardPoint.GetPropertyValue("Transactions") as List<LoyaltyCardTransaction>;
            if (transactions == null || transactions.Count <= 0)
            {
                return;
            }

            foreach (var transaction in transactions)
            {
                var result = new LoyaltyTransactionItemBaseJsonResult();
                result.Initialize(transaction);
                this.Transactions.Add(result);
            }
        }
        /// <summary>
        /// Initializes the specified reward point.
        /// </summary>
        /// <param name="rewardPoint">The reward point.</param>
        public override void Initialize(LoyaltyRewardPoint rewardPoint)
        {
            base.Initialize(rewardPoint);

            this.RewardPointId = ((Sitecore.Commerce.Connect.DynamicsRetail.Entities.LoyaltyPrograms.LoyaltyRewardPoint)rewardPoint).RewardPointId;
        }