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);
        }
        private static HearingSuitability CreateModel(PersonSuitabilityAnswerResponse response)
        {
            var answers = response.Answers.Select(CreateModel);

            return(new HearingSuitability
                   (
                       response.HearingId,
                       response.ParticipantId,
                       response.ScheduledAt,
                       response.QuestionnaireNotRequired,
                       answers
                   ));
        }
Пример #3
0
        public HearingSuitabilityServiceTests()
        {
            _upcomingHearingScheduledAt = DateTime.Now.AddDays(2);
            _questionnaireNotRequired   = true;
            _upcomingHearing            = new PersonSuitabilityAnswerResponse
            {
                HearingId                = Guid.NewGuid(),
                ParticipantId            = Guid.NewGuid(),
                ScheduledAt              = _upcomingHearingScheduledAt,
                QuestionnaireNotRequired = _questionnaireNotRequired,
                Answers = new List <SuitabilityAnswerResponse>()
            };

            _pastHearingId = Guid.NewGuid();
            var pastHearing = new PersonSuitabilityAnswerResponse
            {
                HearingId     = _pastHearingId,
                ParticipantId = Guid.NewGuid(),
                ScheduledAt   = DateTime.UtcNow.AddDays(-2),
                Answers       = new List <SuitabilityAnswerResponse>()
            };

            _answeredQuestion = new SuitabilityAnswerResponse
            {
                Key            = "QUESTION",
                Answer         = "Answer",
                ExtendedAnswer = "Extended answer"
            };

            var submittedHearing = new PersonSuitabilityAnswerResponse
            {
                HearingId     = _submittedHearingId,
                ParticipantId = Guid.NewGuid(),
                ScheduledAt   = DateTime.UtcNow.AddDays(3),
                Answers       = new List <SuitabilityAnswerResponse> {
                    _answeredQuestion
                }
            };

            _hearingsList = new List <PersonSuitabilityAnswerResponse>
            {
                _upcomingHearing,
                pastHearing,
                submittedHearing
            };
        }
Пример #4
0
        private static HearingSuitability CreateModel(PersonSuitabilityAnswerResponse response)
        {
            var answers = response.Answers.Select(CreateModel);

            return(new HearingSuitability(response.Hearing_id.GetValueOrDefault(), response.Scheduled_at.GetValueOrDefault(), answers));
        }