public void should_map_to_representative_confirmation_notification() { var expectedNotificationType = NotificationType.HearingConfirmationRepresentative; var participant = InitParticipant("Representative", "Jane Doe"); var hearing = InitHearing(); var expectedParameters = new Dictionary <string, string> { { "case name", hearing.Cases.First().Name }, { "case number", hearing.Cases.First().Number }, { "time", "2:10 PM" }, { "day month year", "12 October 2020" }, { "solicitor name", $"{participant.FirstName} {participant.LastName}" }, { "client name", $"{participant.Representee}" } }; var result = AddNotificationRequestMapper.MapToHearingConfirmationNotification(hearing, participant); result.Should().NotBeNull(); result.HearingId.Should().Be(hearing.Id); result.ParticipantId.Should().Be(participant.Id); result.ContactEmail.Should().Be(participant.ContactEmail); result.NotificationType.Should().Be(expectedNotificationType); result.MessageType.Should().Be(MessageType.Email); result.PhoneNumber.Should().Be(participant.TelephoneNumber); result.Parameters.Should().BeEquivalentTo(expectedParameters); }
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 void should_map_to_judge_confirmation_notification() { var expectedNotificationType = NotificationType.HearingConfirmationJudge; var participant = InitParticipant("Judge"); var hearing = InitHearing(); hearing.OtherInformation = JsonConvert.SerializeObject(new OtherInformationDetails { JudgeEmail = "*****@*****.**", JudgePhone = "123456789" }); var expectedParameters = new Dictionary <string, string> { { "case name", hearing.Cases.First().Name }, { "case number", hearing.Cases.First().Number }, { "time", "2:10 PM" }, { "day month year", "12 October 2020" }, { "judge", participant.DisplayName }, { "courtroom account username", participant.Username } }; var result = AddNotificationRequestMapper.MapToHearingConfirmationNotification(hearing, participant); result.Should().NotBeNull(); result.HearingId.Should().Be(hearing.Id); result.ParticipantId.Should().Be(participant.Id); result.ContactEmail.Should().Be(participant.ContactEmail); result.NotificationType.Should().Be(expectedNotificationType); result.MessageType.Should().Be(MessageType.Email); result.PhoneNumber.Should().Be(participant.TelephoneNumber); result.Parameters.Should().BeEquivalentTo(expectedParameters); }
public async Task SendHearingConfirmationEmail(HearingDetailsResponse hearing, List <ParticipantResponse> participants = null) { if (hearing.IsGenericHearing()) { return; } var participantsToEmail = participants ?? hearing.Participants; var requests = participantsToEmail .Where(x => !x.UserRoleName.Contains("Judge", StringComparison.CurrentCultureIgnoreCase)) .Select(participant => AddNotificationRequestMapper.MapToHearingConfirmationNotification(hearing, participant)) .ToList(); foreach (var request in requests) { await _notificationApiClient.CreateNewNotificationAsync(request); } }