コード例 #1
0
        public HttpResponseMessage GetEarnHistory()
        {
            Stopwatch callTimer = Stopwatch.StartNew();

            HttpResponseMessage result;

            // Build a context object to pass down the pipeline.
            CommerceContext context = CommerceContext.BuildSynchronousRestContext("Get Earn/Burn history", Request,
                                                                                  new GetEarnBurnTransactionHistoryResponse(), callTimer);

            try
            {
                context.Log.Information("Processing {0} call.", context.ApiCallDescription);

                // Add call parameters.
                context[Key.GlobalUserId]      = CommerceContext.PopulateUserId(context);
                context[Key.RewardProgramType] = RewardPrograms.EarnBurn;

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

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

            return(result);
        }
コード例 #2
0
        public HttpResponseMessage Get(Guid userId)
        {
            HttpResponseMessage result;

            Stopwatch callTimer = Stopwatch.StartNew();

            // Build a context object to pass down the pipeline.
            CommerceContext context = CommerceContext.BuildSynchronousRestContext("Get redemption history", Request,
                                                                                  new GetRedemptionHistoryResponse(), callTimer);

            try
            {
                context.Log.Information("Processing {0} call.", context.ApiCallDescription);
                CustomIdentity clientIdentity = (CustomIdentity)Thread.CurrentPrincipal.Identity;
                context.Log.Verbose("Presented client certificate has subject \"{0}\" and thumbprint \"{1}\".",
                                    clientIdentity.Name, clientIdentity.PresentedClientToken);

                // Add ID for the user making this call to the context.
                context[Key.GlobalUserId]      = userId;
                context[Key.RewardProgramType] = RewardPrograms.CardLinkOffers;

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

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

            return(result);
        }