Пример #1
0
        /// <summary>
        /// Adds the referral in the context to the data store.
        /// </summary>
        /// <returns>
        /// The ResultCode corresponding to the result of the operation.
        /// </returns>
        private ResultCode AddReferralToDataStore()
        {
            ResultCode result = ResultCode.Created;

            Context.Log.Verbose("Adding referral to the data store.");
            Context[Key.ReferredUserFirstEarnRewardAmount]      = CommerceServiceConfig.Instance.ReferredUserFirstEarnRewardAmount;
            Context[Key.ReferredUserFirstEarnRewardExplanation] = CommerceServiceConfig.Instance.ReferredUserFirstEarnRewardExplanation;
            result = ReferralOperations.AddReferral();
            if (result == ResultCode.Created)
            {
                bool referralAdded = (bool)Context[Key.ReferralAdded];
                if (referralAdded == true)
                {
                    Context.Log.Verbose("Referral added to the data store.");
                }
                else
                {
                    result = ResultCode.Success;
                    Context.Log.Verbose("User has reached the per user limit for this referral. " +
                                        "No referral was added to the data store.");
                }
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Gets the users referrals by event type and count.
        /// </summary>
        /// <returns>
        /// The result of the operation.
        /// </returns>
        private ResultCode GetUsersReferrals()
        {
            GetUsersReferralsResponse response = (GetUsersReferralsResponse)Context[Key.Response];

            Context.Log.Verbose("Retrieving user's referrals by event type and count.");
            response.ReferralCodeReports = ReferralOperations.RetrieveReferralCounts();
            Context.Log.Verbose("User's referral events and counts retrieved.");

            return(ResultCode.Success);
        }
        /// <summary>
        /// Adds the referral type in the context to the data store.
        /// </summary>
        /// <returns>
        /// The ResultCode corresponding to the result of the operation.
        /// </returns>
        protected ResultCode AddReferralType()
        {
            ResultCode result = ResultCode.Created;

            Context.Log.Verbose("Adding user referral type to the data store.");
            result = ReferralOperations.AddReferralType();
            if (result == ResultCode.Created)
            {
                Context.Log.Verbose("User referral type added to the data store.");
            }

            return(result);
        }