public BookingsHearingResponseBuilder(HearingDetailsResponse hearingResponse)
 {
     _response = new BookingsHearingResponse()
     {
         AudioRecordingRequired = hearingResponse.AudioRecordingRequired,
         CancelReason = hearingResponse.CancelReason,
         CaseTypeName = hearingResponse.CaseTypeName,
         ConfirmedBy = hearingResponse.ConfirmedBy,
         ConfirmedDate = hearingResponse.ConfirmedDate,
         CourtAddress = string.Empty,
         CourtRoom = string.Empty,
         CourtRoomAccount = string.Empty,
         CreatedBy = hearingResponse.CreatedBy,
         CreatedDate = hearingResponse.CreatedDate,
         GroupId = hearingResponse.GroupId,
         HearingId = hearingResponse.Id,
         HearingName = hearingResponse.Cases.Single().Name,
         HearingNumber = hearingResponse.Cases.Single().Number,
         HearingTypeName = hearingResponse.HearingTypeName,
         JudgeName = hearingResponse.Participants.First(x => x.HearingRoleName.Equals("Judge")).DisplayName,
         LastEditBy = hearingResponse.UpdatedBy,
         LastEditDate = hearingResponse.UpdatedDate,
         QuestionnaireNotRequired = hearingResponse.QuestionnaireNotRequired,
         ScheduledDateTime = hearingResponse.ScheduledDateTime,
         ScheduledDuration = hearingResponse.ScheduledDuration,
         Status = hearingResponse.Status
     };
 }
 public static HearingResponse Map(BookingsHearingResponse response)
 {
     return(new HearingResponse()
     {
         Id = response.HearingId,
         Case_name = response.HearingName,
         ScheduledDate = response.ScheduledDateTime
     });
 }
        public BookingsHearingResponse MapHearingResponse(VideoHearing videoHearing)
        {
            var @case = videoHearing.GetCases().FirstOrDefault();

            if (@case == null)
            {
                throw new ArgumentException("Hearing is missing case");
            }

            if (videoHearing.CaseType == null)
            {
                throw new ArgumentException("Hearing is missing case type");
            }
            if (videoHearing.HearingType == null)
            {
                throw new ArgumentException("Hearing is missing hearing type");
            }

            var judgeParticipant = videoHearing.GetParticipants().FirstOrDefault(s => s.HearingRole?.UserRole != null && s.HearingRole.UserRole.Name == "Judge");
            var judgeName        = judgeParticipant != null ? judgeParticipant.DisplayName : string.Empty;
            var courtRoomAccount = judgeParticipant != null ? judgeParticipant.Person.Username : string.Empty;

            var response = new BookingsHearingResponse
            {
                HearingId                = videoHearing.Id,
                HearingNumber            = @case.Number,
                HearingName              = @case.Name,
                ScheduledDuration        = videoHearing.ScheduledDuration,
                ScheduledDateTime        = videoHearing.ScheduledDateTime,
                HearingTypeName          = videoHearing.HearingType.Name,
                CaseTypeName             = videoHearing.CaseType.Name,
                CourtAddress             = videoHearing.HearingVenueName,
                CourtRoom                = videoHearing.HearingRoomName,
                CreatedDate              = videoHearing.CreatedDate,
                CreatedBy                = videoHearing.CreatedBy,
                LastEditDate             = videoHearing.UpdatedDate,
                LastEditBy               = videoHearing.UpdatedBy,
                ConfirmedBy              = videoHearing.ConfirmedBy,
                ConfirmedDate            = videoHearing.ConfirmedDate,
                JudgeName                = judgeName,
                Status                   = videoHearing.Status.MapToContractEnum(),
                QuestionnaireNotRequired = videoHearing.QuestionnaireNotRequired,
                AudioRecordingRequired   = videoHearing.AudioRecordingRequired,
                CancelReason             = videoHearing.CancelReason,
                GroupId                  = videoHearing.SourceId,
                CourtRoomAccount         = courtRoomAccount
            };

            return(response);
        }