Esempio n. 1
0
        /// <summary>
        /// Retrieve all currently active discounts in the system
        /// </summary>
        /// <returns>
        /// Enumeration of all such discount ids
        /// </returns>
        public IEnumerable <Guid> RetrieveActiveDiscountIds()
        {
            List <Guid> result = new List <Guid>();

//TODO: Receiving ReimbursementTender.MicrosoftBurn is a hack. Since ReimbursementTender was not intended for bitmasking, it has neither a None nor an All.
//       Until this can be changed, sending Burn will be treated the same as DealCurrency | MicrosoftBurn would be were it an option. Since masking is not an
//       option, there's an additional hack to translate this into "exclude Earn deals". All this can be cleaned up when First Data has been deprecated and can be removed.
            ReimbursementTender reimbursementTender = ReimbursementTender.DeprecatedBurn;

            if (Context.ContainsKey(Key.RewardProgramType) == true)
            {
                reimbursementTender = (ReimbursementTender)Context[Key.ReimbursementTender];
            }

            SqlProcedure("GetActiveDealIds",
                         new Dictionary <string, object>
            {
                { "@excludeEarn", reimbursementTender != ReimbursementTender.MicrosoftEarn },
                { "@partnerId", Context[Key.Partner] }
            },
                         (sqlDataReader) =>
            {
                while (sqlDataReader.Read() == true)
                {
                    result.Add(sqlDataReader.GetGuid(sqlDataReader.GetOrdinal("GlobalId")));
                }
            });

            Context.Log.Verbose("RetrieveActiveDiscountIds retrieved {0} Discounts.", result.Count);

            return(result);
        }
Esempio n. 2
0
        public HttpResponseMessage ActiveDiscountIds(ReimbursementTender reimbursementTender = ReimbursementTender.DeprecatedEarn,
                                                     Partner partner = Partner.None)
        {
            Stopwatch callTimer = Stopwatch.StartNew();

            HttpResponseMessage result;

            // Build a context object to pass down the pipeline.
            CommerceContext context = CommerceContext.BuildSynchronousRestContext("Get Active Discounts", Request, new GetActiveDiscountIdsResponse(),
                                                                                  callTimer);

            try
            {
                context.Log.Information("Processing {0} call.", context.ApiCallDescription);
                CustomIdentity clientIdentity = (CustomIdentity)Thread.CurrentPrincipal.Identity;
                context.Log.Verbose("Presented credentials are for role \"{0}\" and include token \"{1}\".",
                                    clientIdentity.Name, clientIdentity.PresentedClientToken);

                context[Key.ReimbursementTender] = reimbursementTender;
                context[Key.Partner]             = partner;

                // Create an executor object to execute the API invocation.
                GetActiveDiscountsExecutor discountsExecutor = new GetActiveDiscountsExecutor(context);
                discountsExecutor.Execute();

                // Build the response from the result of API invocation.
                result = RestResponder.BuildSynchronousResponse(context);
            }
            catch (Exception ex)
            {
                result = RestResponder.BuildSynchronousResponse(context, ex);
            }

            return(result);
        }
        /// <summary>
        /// Determines which redemption type to apply based on the tender,
        /// </summary>
        /// <param name="reimbursementTenderId">
        /// The tender used to determine the redemption type.
        /// </param>
        /// <returns>
        /// The redemption type for the transaction.
        /// </returns>
        private string GetRedemptionTypeForEarnBurn(ReimbursementTender reimbursementTender)
        {
            string redemptionType = null;

            if (reimbursementTender == ReimbursementTender.MicrosoftEarn)
            {
                redemptionType = EarnRedemption;
            }
            else if (reimbursementTender == ReimbursementTender.MicrosoftBurn)
            {
                redemptionType = BurnRedemption;
            }

            return(redemptionType);
        }