Exemplo n.º 1
0
        /// <summary>
        /// Processes the response.
        /// </summary>
        /// <param name="enquiryResponse">The enquiry response.</param>
        /// <returns>EnquiryResult object populated from the web service response.</returns>
        private EnquiryResult ProcessResponse(EnquiryResponse enquiryResponse)
        {
            Logger.Debug("EnquiryFactory.ProcessResponse executing.");

            EnquiryResult enquiryResult = new EnquiryResult();

            if (enquiryResponse != null)
            {
                if (!string.IsNullOrEmpty(enquiryResponse.EnquiryNumber))
                {
                    enquiryResult.ResultStatus = ResultStatus.Success;
                    enquiryResult.EnquiryNumber = enquiryResponse.EnquiryNumber.Replace("Your enquiry reference is:", "").Trim();
                }
                else
                {
                    string returnedError = "UNDEFINED";
                    string errorDescription = "UNDEFINED";

                    if (enquiryResponse.Error != null)
                    {
                        returnedError = enquiryResponse.Error;
                        errorDescription = enquiryResponse.ErrorDescription ?? "UNDEFINED";
                    }

                    enquiryResult.ResultStatus = ResultStatus.Error;
                    enquiryResult.Errors = new List<string> { returnedError, errorDescription };

                    Logger.ErrorFormat("EnquiryFactory.ProcessResponse failed with Error: {0}; ErrorDescription: {1}.", returnedError, errorDescription);
                }
            }
            else
            {
                string returnedError = "UNDEFINED";
                string errorDescription = "UNDEFINED";

                if (enquiryResponse.Error != null)
                {
                    returnedError = enquiryResponse.Error;
                    errorDescription = enquiryResponse.ErrorDescription ?? "UNDEFINED";
                }

                enquiryResult.ResultStatus = ResultStatus.Error;
                enquiryResult.Errors = new List<string> { returnedError, errorDescription };

                // log the error
                Logger.ErrorFormat("EnquiryFactory.ProcessResponse failed with Error: {0}; ErrorDescription: {1}.", returnedError, errorDescription);
            }

            return enquiryResult;
        }
Exemplo n.º 2
0
 public EnquiryResponseWrapper(EnquiryResponse enquiryResponse)
 {
     this.EnquiryResponse = enquiryResponse;
 }