Exemple #1
0
        public string GetResultList(RequestData requestData, DateTime requestDateTime)
        {
            string   jsonData        = string.Empty;
            string   jsonRequestData = string.Empty;
            DateTime requestStart    = DateTime.Now;

            try
            {
                jsonRequestData = JsonConvert.SerializeObject(requestData);

                List <ResultDTO> resultsDTO = new List <ResultDTO>();
                using (ResultsRepository questionnaireRepository = new ResultsRepository())
                {
                    resultsDTO = questionnaireRepository.GetAvailableQuestionnaires(requestData.orgNumber, requestData.baseName, requestData.isCreditCardItem);
                }

                List <Result> resultList = new List <Result>();
                foreach (ResultDTO question in resultsDTO)
                {
                    Result result = new Result();
                    result.MasterQuestionnaireID = question.MasterQuestionnaireID;
                    result.description           = question.Description;
                    result.updatedDate           = question.UpdatedDate.ToString();
                    result.updatedByUserName     = question.UpdatedByUserName;
                    result.baseForms             = question.BaseForms;
                    result.CreditCards           = null; //initialize as null, will add value later if .isCreditCardItem is true
                    result.CreditCardGroups      = null; //initialize as null, will add value later if .isCreditCardItem is true
                    if (requestData.isCreditCardItem)
                    {
                        //add the new fields to the QuestionnaireData object and assign them here.
                        result.CreditCards               = question.CreditCards;      //JsonConvert.SerializeObject(question.CreditCards).Replace("/","");
                        result.CreditCardGroups          = question.CreditCardGroups; //JsonConvert.SerializeObject(question.CreditCardGroups).Replace("/", "");
                        result.CreditCardParsingPassed   = question.CreditCardParsingPassed;
                        result.CreditCardValidationError = question.CreditCardValidationError;
                    }

                    resultList.Add(result);
                }

                jsonData = JsonConvert.SerializeObject(resultList);
            }
            catch (Exception ex)
            {
                Logger.LogCustomError(ex.ToString(), LogInformation.LogFilePath);
                jsonData = "Exception occured. Kindly contact IT Support.";
            }
            finally
            {
                LogCommunication(jsonRequestData, requestStart, jsonData);
            }
            return(jsonData);
        }