コード例 #1
0
        private static PersonSuitabilityAnswerResponse BuildResponse(Hearing hearing, string username)
        {
            PersonSuitabilityAnswerResponse personSuitabilityAnswer = null;

            if (hearing.Participants != null)
            {
                var participant = hearing.Participants.FirstOrDefault(p => p.Person.Username.ToLower() == username.Trim().ToLower());
                if (participant != null)
                {
                    var answers = participant.Questionnaire != null ? participant.Questionnaire.SuitabilityAnswers : new List <SuitabilityAnswer>();
                    var suitabilityAnswerToResponseMapper = new SuitabilityAnswerToResponseMapper();
                    personSuitabilityAnswer = new PersonSuitabilityAnswerResponse
                    {
                        HearingId                = hearing.Id,
                        ParticipantId            = participant.Id,
                        UpdatedAt                = participant.Questionnaire?.UpdatedDate ?? DateTime.MinValue,
                        ScheduledAt              = hearing.ScheduledDateTime,
                        Answers                  = suitabilityAnswerToResponseMapper.MapToResponses(answers),
                        QuestionnaireNotRequired = hearing.QuestionnaireNotRequired
                    };
                }
            }

            return(personSuitabilityAnswer);
        }
        public void SetUp()
        {
            mapper = new SuitabilityAnswerToResponseMapper();

            var answer1 = new SuitabilityAnswer("AboutYou", "Yes", null);
            var answer2 = new SuitabilityAnswer("AboutClient", "No", "note");
            var answer3 = new SuitabilityAnswer("AboutCpmputer", "Yes", "");

            suitabilityAnswers = new List <SuitabilityAnswer> {
                answer1, answer2, answer3
            };
        }