public async Task SendJudgeConfirmationEmail(HearingDetailsResponse hearing) { var hearings = await _bookingsApiClient.GetHearingsByGroupIdAsync(hearing.GroupId.Value); AddNotificationRequest request; if (hearings.Count == 1) { var judge = hearing.Participants .First(x => x.UserRoleName.Contains("Judge", StringComparison.CurrentCultureIgnoreCase)); request = AddNotificationRequestMapper.MapToHearingConfirmationNotification(hearing, judge); } else { var firstHearingForGroup = hearings.First(); if (firstHearingForGroup.Id != hearing.Id) { return; } var judge = firstHearingForGroup.Participants.First(x => x.UserRoleName.Contains("Judge", StringComparison.CurrentCultureIgnoreCase)); request = AddNotificationRequestMapper.MapToMultiDayHearingConfirmationNotification(firstHearingForGroup, judge, hearings.Count); } if (request.ContactEmail != null) { await _notificationApiClient.CreateNewNotificationAsync(request); } }
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 async Task ProcessExistingParticipants(Guid hearingId, HearingDetailsResponse hearing, EditParticipantRequest participant) { var existingParticipant = hearing.Participants.FirstOrDefault(p => p.Id.Equals(participant.Id)); if (existingParticipant != null) { if (existingParticipant.UserRoleName == "Individual" || existingParticipant.UserRoleName == "Representative") { //Update participant _logger.LogDebug("Updating existing participant {Participant} in hearing {Hearing}", existingParticipant.Id, hearingId); var updateParticipantRequest = UpdateParticipantRequestMapper.MapTo(participant); await _bookingsApiClient.UpdateParticipantDetailsAsync(hearingId, participant.Id.Value, updateParticipantRequest); } else if (existingParticipant.UserRoleName == "Judge") { //Update Judge _logger.LogDebug("Updating judge {Participant} in hearing {Hearing}", existingParticipant.Id, hearingId); var updateParticipantRequest = new UpdateParticipantRequest { DisplayName = participant.DisplayName }; await _bookingsApiClient.UpdateParticipantDetailsAsync(hearingId, participant.Id.Value, updateParticipantRequest); } } }
public static void HearingDetailsResponse(HearingDetailsResponse response, CreateHearingRequest request) { response.AudioRecordingRequired.Should().Be(request.AudioRecordingRequired); response.CancelReason.Should().BeNull(); response.CaseTypeName.Should().Be(request.CaseType); response.Cases.First().Name.Should().Contain(request.TestType.ToString()); response.Cases.First().Number.Should().NotBeNullOrWhiteSpace(); response.Cases.First().IsLeadCase.Should().Be(HearingData.IS_LEAD_CASE); response.ConfirmedBy.Should().BeNull(); response.ConfirmedDate.Should().BeNull(); VerifyCreatedBy(response, request); response.CreatedDate.Should().BeCloseTo(DateTime.UtcNow, TimeSpan.FromSeconds(30)); response.HearingRoomName.Should().Be(HearingData.HEARING_ROOM_NAME); response.HearingTypeName.Should().Be(request.CaseType.Equals(HearingData.CASE_TYPE_NAME) ? HearingData.HEARING_TYPE_NAME : HearingData.CACD_HEARING_TYPE_NAME); response.HearingVenueName.Should().Be(request.Venue); response.Id.Should().NotBeEmpty(); response.OtherInformation.Should().Be(HearingData.OTHER_INFORMATION); var expectedCount = UsersIncludeCaseAdminOrVho(request.Users) ? request.Users.Count - 1 : request.Users.Count; response.Participants.Count.Should().Be(expectedCount); response.QuestionnaireNotRequired.Should().Be(request.QuestionnaireNotRequired); response.ScheduledDateTime.Should().Be(request.ScheduledDateTime); response.ScheduledDuration.Should().Be(HearingData.SCHEDULED_DURATION); response.Status.Should().Be(BookingStatus.Booked); response.UpdatedBy.Should().BeNull(); response.UpdatedDate.Should().BeCloseTo(DateTime.UtcNow, TimeSpan.FromSeconds(30)); VerifyHearingParticipants(response.Participants, request.Users); }
public async Task SendHearingUpdateEmail(HearingDetailsResponse originalHearing, HearingDetailsResponse updatedHearing, List <ParticipantResponse> participants = null) { if (updatedHearing.IsGenericHearing()) { return; } var @case = updatedHearing.Cases.First(); var caseName = @case.Name; var caseNumber = @case.Number; var participantsToEmail = participants ?? updatedHearing.Participants; if (!updatedHearing.DoesJudgeEmailExist() || originalHearing.ConfirmedDate == null || originalHearing.GroupId != originalHearing.Id) { participantsToEmail = participantsToEmail .Where(x => !x.UserRoleName.Contains("Judge", StringComparison.CurrentCultureIgnoreCase)) .ToList(); } var requests = participantsToEmail .Select(participant => AddNotificationRequestMapper.MapToHearingAmendmentNotification(updatedHearing, participant, caseName, caseNumber, originalHearing.ScheduledDateTime, updatedHearing.ScheduledDateTime)) .ToList(); foreach (var request in requests) { await _notificationApiClient.CreateNewNotificationAsync(request); } }
private void AddParticipants(HearingDetailsResponse hearing) { _response.Participants = new List <ParticipantDetailsResponse>(); foreach (var participant in hearing.Participants) { Enum.TryParse(participant.UserRoleName, out UserRole role); var response = new ParticipantDetailsResponse() { CaseTypeGroup = participant.UserRoleName, ContactEmail = participant.ContactEmail, ContactTelephone = participant.Title, CurrentStatus = ParticipantState.NotSignedIn, DisplayName = participant.DisplayName, FirstName = participant.FirstName, HearingRole = participant.UserRoleName, Id = participant.Id, LastName = participant.LastName, Name = participant.DisplayName, RefId = participant.Id, Representee = participant.Representee, UserRole = role, Username = participant.Username }; _response.Participants.Add(response); } }
public void Setup() { _hearing = new HearingDetailsResponse { Id = Guid.NewGuid() }; }
private void SubmitAnswers(IEnumerable <SuitabilityAnswersRequest> answers, HearingDetailsResponse hearing) { var participantId = hearing.Participants.First(x => x.LastName.ToLower().Equals(_c.CurrentUser.LastName.ToLower())).Id; var response = _c.Api.SetSuitabilityAnswers(hearing.Id, participantId, answers); response.StatusCode.Should().Be(HttpStatusCode.NoContent); }
private async Task SendJudgeEmailIfNeeded(HearingDetailsResponse updatedHearing, HearingDetailsResponse originalHearing) { if (updatedHearing.HasJudgeEmailChanged(originalHearing) && updatedHearing.Status == BookingStatus.Created) { await _hearingsService.SendJudgeConfirmationEmail(updatedHearing); } }
private static void VerifyCreatedBy(HearingDetailsResponse response, CreateHearingRequest request) { response.CreatedBy.Should().Be( UsersIncludeCaseAdminOrVho(request.Users) ? request.Users.First(x => x.UserType == UserType.CaseAdmin || x.UserType == UserType.VideoHearingsOfficer).Username : UserData.DEFAULT_CREATED_BY_USER); }
public static bool HasJudgeEmailChanged(this HearingDetailsResponse hearing, HearingDetailsResponse anotherHearing) { if (string.IsNullOrWhiteSpace(anotherHearing.OtherInformation) && string.IsNullOrWhiteSpace(hearing.OtherInformation)) { return(false); } return(hearing.GetJudgeEmail() != anotherHearing.GetJudgeEmail()); }
public static HearingDetailsResponse WithEndPoints(this HearingDetailsResponse hearingDetailsResponse, int size) { var endPoints = Builder <EndpointResponse> .CreateListOfSize(size).Build().ToList(); hearingDetailsResponse.Endpoints = endPoints; return(hearingDetailsResponse); }
private async Task RemoveEndpointsFromHearing(HearingDetailsResponse hearing, IEnumerable <EndpointResponse> listOfEndpointsToDelete) { foreach (var endpointToDelete in listOfEndpointsToDelete) { _logger.LogDebug("Removing endpoint {Endpoint} - {EndpointDisplayName} from hearing {Hearing}", endpointToDelete.Id, endpointToDelete.DisplayName, hearing.Id); await _bookingsApiClient.RemoveEndPointFromHearingAsync(hearing.Id, endpointToDelete.Id); } }
private static void AssertDetails(HearingDetailsResponse hearing, Test testData) { hearing.Cases.First().Name.Should().Contain(testData.HearingDetails.CaseName); hearing.Cases.First().Number.Should().Contain(testData.HearingDetails.CaseNumber); hearing.CaseTypeName.Should().Be(testData.HearingDetails.CaseType.Name); hearing.HearingRoomName.Should().Be(testData.HearingSchedule.Room); hearing.HearingTypeName.Should().Be(testData.HearingDetails.HearingType.Name); hearing.HearingVenueName.Should().Be(testData.HearingSchedule.HearingVenue); OtherInformationSteps.GetOtherInfo(hearing.OtherInformation).Should().Be(OtherInformationSteps.GetOtherInfo(testData.TestData.OtherInformationDetails.OtherInformation)); }
public static string GetJudgePhone(this HearingDetailsResponse hearing) { var phone = GetOtherInformationObject(hearing.OtherInformation).JudgePhone; if (phone == string.Empty) { return(null); } return(phone); }
public static string GetJudgeEmail(this HearingDetailsResponse hearing) { var email = GetOtherInformationObject(hearing.OtherInformation)?.JudgeEmail; if (email == string.Empty) { return(null); } return(email); }
private string GetJudgeEmail(HearingDetailsResponse hearing) { var email = GetOtherInformationObject(hearing.OtherInformation).JudgeEmail; if (email == string.Empty) { return(null); } return(email); }
private static void AssertQuestionnaire(HearingDetailsResponse hearing, Test testData) { if (!hearing.Cases.First().Name.Contains("Day") || hearing.Cases.First().Name.Contains("Day 1 of")) { hearing.QuestionnaireNotRequired.Should().BeFalse(); } else { hearing.QuestionnaireNotRequired.Should().BeTrue(); } }
public static AddNotificationRequest MapToMultiDayHearingConfirmationNotification( HearingDetailsResponse hearing, ParticipantResponse participant, int days) { var @case = hearing.Cases.First(); var cleanedCaseName = @case.Name.Replace($"Day 1 of {days}", string.Empty).Trim(); var parameters = new Dictionary <string, string> { { "case name", cleanedCaseName }, { "case number", @case.Number }, { "time", hearing.ScheduledDateTime.ToEmailTimeGbLocale() }, { "Start Day Month Year", hearing.ScheduledDateTime.ToEmailDateGbLocale() }, { "number of days", days.ToString() } }; NotificationType notificationType; if (participant.UserRoleName.Contains("Judge", StringComparison.InvariantCultureIgnoreCase)) { notificationType = NotificationType.HearingConfirmationJudgeMultiDay; parameters.Add("judge", participant.DisplayName); parameters.Add("courtroom account username", participant.Username); participant.ContactEmail = hearing.GetJudgeEmail(); participant.TelephoneNumber = hearing.GetJudgePhone(); } else if (participant.UserRoleName.Contains("Judicial Office Holder", StringComparison.InvariantCultureIgnoreCase)) { notificationType = NotificationType.HearingConfirmationJohMultiDay; parameters.Add("judicial office holder", $"{participant.FirstName} {participant.LastName}"); } else if (participant.UserRoleName.Contains("Representative", StringComparison.InvariantCultureIgnoreCase)) { notificationType = NotificationType.HearingConfirmationRepresentativeMultiDay; parameters.Add("client name", participant.Representee); parameters.Add("solicitor name", $"{participant.FirstName} {participant.LastName}"); } else { notificationType = NotificationType.HearingConfirmationLipMultiDay; parameters.Add("name", $"{participant.FirstName} {participant.LastName}"); } return(new AddNotificationRequest { HearingId = hearing.Id, MessageType = MessageType.Email, ContactEmail = participant.ContactEmail, NotificationType = notificationType, ParticipantId = participant.Id, PhoneNumber = participant.TelephoneNumber, Parameters = parameters }); }
public static AddNotificationRequest MapToHearingAmendmentNotification(HearingDetailsResponse hearing, ParticipantResponse participant, string caseName, string caseNumber, DateTime originalDateTime, DateTime newDateTime) { var parameters = new Dictionary <string, string> { { "case name", caseName }, { "case number", caseNumber }, { "Old time", originalDateTime.ToEmailTimeGbLocale() }, { "New time", newDateTime.ToEmailTimeGbLocale() }, { "Old Day Month Year", originalDateTime.ToEmailDateGbLocale() }, { "New Day Month Year", newDateTime.ToEmailDateGbLocale() } }; NotificationType notificationType; if (participant.UserRoleName.Contains("Judge", StringComparison.InvariantCultureIgnoreCase)) { notificationType = NotificationType.HearingAmendmentJudge; parameters.Add("judge", participant.DisplayName); parameters.Add("courtroom account username", participant.Username); participant.ContactEmail = hearing.GetJudgeEmail(); participant.TelephoneNumber = hearing.GetJudgePhone(); } else if (participant.UserRoleName.Contains("Judicial Office Holder", StringComparison.InvariantCultureIgnoreCase)) { notificationType = NotificationType.HearingAmendmentJoh; parameters.Add("judicial office holder", $"{participant.FirstName} {participant.LastName}"); } else if (participant.UserRoleName.Contains("Representative", StringComparison.InvariantCultureIgnoreCase)) { notificationType = NotificationType.HearingAmendmentRepresentative; parameters.Add("client name", participant.Representee); parameters.Add("solicitor name", $"{participant.FirstName} {participant.LastName}"); } else { notificationType = NotificationType.HearingAmendmentLip; parameters.Add("name", $"{participant.FirstName} {participant.LastName}"); } return(new AddNotificationRequest { HearingId = hearing.Id, MessageType = MessageType.Email, ContactEmail = participant.ContactEmail, NotificationType = notificationType, ParticipantId = participant.Id, PhoneNumber = participant.TelephoneNumber, Parameters = parameters }); }
public static bool DoesJudgePhoneExist(this HearingDetailsResponse hearing) { if (hearing.OtherInformation != null) { var otherInformationDetails = GetOtherInformationObject(hearing.OtherInformation); if (otherInformationDetails.JudgePhone != null) { return(true); } } return(false); }
private async Task ConfirmMultiDayHearing(HearingDetailsResponse hearing) { var confirmRequest = new UpdateBookingStatusRequestBuilder() .UpdatedBy(HearingData.CREATED_BY(Context.Config.UsernameStem)) .Build(); await BookingApiClient.UpdateBookingStatusAsync(hearing.Id, confirmRequest); Conference = await GetConferenceByHearingIdPollingAsync(hearing.Id); Verify.ConferenceDetailsResponse(Conference, hearing); }
private async Task AddEndpointToHearing(Guid hearingId, HearingDetailsResponse hearing, EditEndpointRequest endpoint) { _logger.LogDebug("Adding endpoint {EndpointDisplayName} to hearing {Hearing}", endpoint.DisplayName, hearingId); var addEndpointRequest = new AddEndpointRequest { DisplayName = endpoint.DisplayName, DefenceAdvocateUsername = endpoint.DefenceAdvocateUsername }; await _bookingsApiClient.AddEndPointToHearingAsync(hearing.Id, addEndpointRequest); }
private static Dictionary <string, string> InitConfirmReminderParams(HearingDetailsResponse hearing) { var @case = hearing.Cases.First(); return(new Dictionary <string, string> { { "case name", @case.Name }, { "case number", @case.Number }, { "time", hearing.ScheduledDateTime.ToEmailTimeGbLocale() }, { "day month year", hearing.ScheduledDateTime.ToEmailDateGbLocale() } }); }
private async Task RemoveParticipantsFromHearing(Guid hearingId, EditHearingRequest request, HearingDetailsResponse originalHearing) { var deleteParticipantList = originalHearing.Participants.Where(p => request.Participants.All(rp => rp.Id != p.Id)); foreach (var participantToDelete in deleteParticipantList) { _logger.LogDebug("Removing existing participant {Participant} from hearing {Hearing}", participantToDelete.Id, hearingId); await _bookingsApiClient.RemoveParticipantFromHearingAsync(hearingId, participantToDelete.Id); } }
private static Hearing Map(HearingDetailsResponse response) { var hearingCase = response.Cases.FirstOrDefault(c => c.Is_lead_case.Value) ?? response.Cases.First(); return(new Hearing( response.Id.Value, hearingCase.Name, hearingCase.Number, response.Scheduled_date_time.Value, response.Case_type_name, response.Hearing_type_name )); }
public void MatchesHearing(HearingDetailsResponse hearing) { var hearingCase = hearing.Cases.First(); _conference.Case_name.Should().Be(hearingCase.Name); _conference.Case_number.Should().Be(hearingCase.Number); _conference.Case_type.Should().Be(hearing.Case_type_name); _conference.Current_status.Should().Be(ConferenceState.NotStarted); _conference.Hearing_id.Should().Be(hearing.Id); _conference.Scheduled_date_time.Should().Be(hearing.Scheduled_date_time); _conference.Scheduled_duration.Should().Be(hearing.Scheduled_duration); ParticipantsMatch(hearing.Participants); }
private static Hearing Map(HearingDetailsResponse response) { var hearingCase = response.Cases.FirstOrDefault(c => c.IsLeadCase) ?? response.Cases.First(); return(new Hearing( response.Id, hearingCase.Name, hearingCase.Number, response.ScheduledDateTime, response.CaseTypeName, response.HearingTypeName )); }
private async Task SendEmailsToParticipantsAddedToHearing(List <ParticipantRequest> newParticipantList, HearingDetailsResponse updatedHearing, Dictionary <string, User> usernameAdIdDict, IEnumerable <string> newParticipantEmails) { if (newParticipantList.Any()) { _logger.LogInformation("Sending email notification to the participants"); await _hearingsService.SendNewUserEmailParticipants(updatedHearing, usernameAdIdDict); var participantsForConfirmation = updatedHearing.Participants .Where(p => newParticipantEmails.Contains(p.ContactEmail)).ToList(); await _hearingsService.SendHearingConfirmationEmail(updatedHearing, participantsForConfirmation); _logger.LogInformation("Successfully sent emails to participants - {Hearing}", updatedHearing.Id); } }
public static HearingDetailsResponse WithParticipant(this HearingDetailsResponse hearingDetailsResponse, string userRoleName, string userName = null) { var participant = Builder <ParticipantResponse> .CreateNew() .With(x => x.Id = Guid.NewGuid()) .With(x => x.UserRoleName = userRoleName); if (!string.IsNullOrEmpty(userName)) { participant.With(x => x.Username = userName); } hearingDetailsResponse.Participants.Add(participant.Build()); return(hearingDetailsResponse); }