public HttpResponseMessage GenerateReport(MerchantReportQuery merchantReportQuery) { Stopwatch callTimer = Stopwatch.StartNew(); HttpResponseMessage result; // Build a context object to pass down the pipeline. CommerceContext context = CommerceContext.BuildSynchronousRestContext("Get merchant report", Request, new GetMerchantReportResponse(), 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 query to the context. context[Key.MerchantReportQuery] = merchantReportQuery; // Create an executor object to execute the API invocation. GetMerchantReportExecutor executor = new GetMerchantReportExecutor(context); executor.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> /// Extracts parameters from the context and validates their state. /// </summary> /// <returns> /// The result of the operation. /// </returns> private ResultCode ExtractParameters() { ResultCode result = ResultCode.Success; if (Context.ContainsKey(Key.MerchantReportQuery) == true) { MerchantReportQuery merchantReportQuery = (MerchantReportQuery)Context[Key.MerchantReportQuery]; if (merchantReportQuery.EndDay == DateTime.MinValue) { merchantReportQuery.EndDay = DateTime.MaxValue; } if (merchantReportQuery.StartDay > merchantReportQuery.EndDay) { result = ResultCode.InvalidParameter; } } else { result = ResultCode.ParameterCannotBeNull; } return(result); }