/// <summary> /// Initializes a new instance of the <see cref="SurveyQuestionResultAnswerDTO"/> class. /// </summary> /// <param name="answer"> /// The result. /// </param> public SurveyQuestionResultAnswerDTO(SurveyQuestionResultAnswer answer) { this.surveyQuestionResultAnswerId = answer.Id; this.surveyQuestionResultId = answer.SurveyQuestionResult.With(x => x.Id); this.value = answer.Value; this.surveyDistractorId = answer.SurveyDistractor.Return(x => x.Id, (int?)null); this.surveyDistractorAnswerId = answer.SurveyDistractorAnswer.Return(x => x.Id, (int?)null); this.questionId = answer.SurveyQuestionResult.With(x => x.QuestionRef.Id); this.questionTypeId = answer.SurveyQuestionResult.With(x => x.QuestionType.Id); }
private SurveyQuestionResultAnswer ConvertDto(SurveyQuestionResultAnswerDTO resultDTO, SurveyQuestionResult result) { SurveyQuestionResultAnswer instance = new SurveyQuestionResultAnswer(); instance.Value = resultDTO.value; instance.SurveyDistractorAnswer = resultDTO.surveyDistractorAnswerId.HasValue ? this.DistractorModel.GetOneById(resultDTO.surveyDistractorAnswerId.Value).Value : null; instance.SurveyDistractor = resultDTO.surveyDistractorId.HasValue ? this.DistractorModel.GetOneById(resultDTO.surveyDistractorId.Value).Value : null; instance.SurveyQuestionResult = result; return(instance); }