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 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 void should_map_to_lip_confirmation_notification() { var expectedNotificationType = NotificationType.HearingConfirmationLipMultiDay; var participant = InitParticipant("Individual"); var hearing = InitHearing(); var expectedParameters = new Dictionary <string, string> { { "case name", CaseName }, { "case number", hearing.Cases.First().Number }, { "time", "2:10 PM" }, { "Start Day Month Year", "12 October 2020" }, { "name", $"{participant.FirstName} {participant.LastName}" }, { "number of days", "4" } }; var result = AddNotificationRequestMapper.MapToMultiDayHearingConfirmationNotification(hearing, participant, 4); 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 void should_map_to_joh_confirmation_notification() { var expectedNotificationType = NotificationType.HearingReminderJoh; var participant = InitParticipant("Judicial Office Holder"); 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" }, { "judicial office holder", $"{participant.FirstName} {participant.LastName}" }, { "username", participant.Username } }; var result = AddNotificationRequestMapper.MapToHearingReminderNotification(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 void should_map_to_lip_hearing_amendment_notification() { var expectedNotificationType = NotificationType.HearingAmendmentLip; var oldDate = new DateTime(2020, 2, 10, 11, 30, 0, DateTimeKind.Utc); var newDate = new DateTime(2020, 10, 12, 13, 10, 0, DateTimeKind.Utc); var caseName = "cse test"; var caseNumber = "MBFY/17364"; var participant = InitParticipant("Individual"); var expectedParameters = new Dictionary <string, string> { { "case name", caseName }, { "case number", caseNumber }, { "name", $"{participant.FirstName} {participant.LastName}" }, { "Old time", "11:30 AM" }, { "New time", "2:10 PM" }, { "Old Day Month Year", "10 February 2020" }, { "New Day Month Year", "12 October 2020" } }; var result = AddNotificationRequestMapper.MapToHearingAmendmentNotification(_hearing, participant, caseName, caseNumber, oldDate, newDate); 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 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); } }
public async Task SendMultiDayHearingConfirmationEmail(HearingDetailsResponse hearing, int days) { if (hearing.IsGenericHearing()) { return; } var requests = hearing.Participants .Where(x => !x.UserRoleName.Contains("Judge", StringComparison.CurrentCultureIgnoreCase)) .Select(participant => AddNotificationRequestMapper.MapToMultiDayHearingConfirmationNotification(hearing, participant, days)) .ToList(); foreach (var request in requests) { await _notificationApiClient.CreateNewNotificationAsync(request); } }
public async Task SendHearingReminderEmail(HearingDetailsResponse hearing) { if (hearing.IsGenericHearing()) { return; } if (hearing.DoesJudgeEmailExist()) { await SendJudgeConfirmationEmail(hearing); } var requests = hearing.Participants .Where(x => !x.UserRoleName.Contains("Judge", StringComparison.CurrentCultureIgnoreCase)) .Select(participant => AddNotificationRequestMapper.MapToHearingReminderNotification(hearing, participant)) .ToList(); await Task.WhenAll(requests.Select(_notificationApiClient.CreateNewNotificationAsync)); }
public async Task SendNewUserEmailParticipants(HearingDetailsResponse hearing, Dictionary <string, User> newUsernameAdIdDict) { foreach (var item in newUsernameAdIdDict) { if (!string.IsNullOrEmpty(item.Value?.Password)) { var participant = hearing.Participants.FirstOrDefault(x => x.Username == item.Key); if (participant == null) { continue; } var request = AddNotificationRequestMapper.MapToNewUserNotification(hearing.Id, participant, item.Value.Password); // Send a notification only for the newly created users await _notificationApiClient.CreateNewNotificationAsync(request); } } }
public void Should_map_properties_for_notification_request_for_representative() { var hearingId = Guid.NewGuid(); var participantId = Guid.NewGuid(); var firstName = "firstname"; var lastName = "lastname"; var userName = "******"; var password = "******"; var parameters = new Dictionary <string, string> { { "name", $"{firstName} {lastName}" }, { "username", $"{userName}" }, { "random password", $"{password}" } }; var source = new ParticipantResponse { Id = participantId, Username = userName, CaseRoleName = "caserolename", ContactEmail = "*****@*****.**", FirstName = firstName, HearingRoleName = "hearingrolename", LastName = lastName, TelephoneNumber = "0123456789", UserRoleName = "Representative" }; var result = AddNotificationRequestMapper.MapToNewUserNotification(hearingId, source, password); result.Should().NotBeNull(); result.HearingId.Should().Be(hearingId); result.ParticipantId.Should().Be(participantId); result.ContactEmail.Should().Be(source.ContactEmail); result.NotificationType.Should().Be(NotificationType.CreateRepresentative); result.MessageType.Should().Be(MessageType.Email); result.PhoneNumber.Should().Be(source.TelephoneNumber); result.Parameters.Should().BeEquivalentTo(parameters); }
public void should_map_to_judge_hearing_amendment_notification() { var expectedNotificationType = NotificationType.HearingAmendmentJudge; var oldDate = new DateTime(2020, 2, 10, 11, 30, 0, DateTimeKind.Utc); var newDate = new DateTime(2020, 10, 12, 13, 10, 0, DateTimeKind.Utc); var caseName = "cse test"; var caseNumber = "MBFY/17364"; var participant = InitParticipant("Judge"); _hearing.OtherInformation = JsonConvert.SerializeObject(new OtherInformationDetails { JudgeEmail = "*****@*****.**", JudgePhone = "123456789" }); var expectedParameters = new Dictionary <string, string> { { "case name", caseName }, { "case number", caseNumber }, { "judge", participant.DisplayName }, { "courtroom account username", participant.Username }, { "Old time", "11:30 AM" }, { "New time", "2:10 PM" }, { "Old Day Month Year", "10 February 2020" }, { "New Day Month Year", "12 October 2020" } }; var result = AddNotificationRequestMapper.MapToHearingAmendmentNotification(_hearing, participant, caseName, caseNumber, oldDate, newDate); 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 ResetParticipantPassword(string userName) { _logger.LogDebug("Attempting to reset AD user {Username}", userName); var userProfile = await _userApiClient.GetUserByAdUserNameAsync(userName); if (userProfile == null) { var e = new UserServiceException { Reason = "Unable to generate new password" }; _logger.LogError(e, "Unable to reset password for AD user {Username}", userName); throw e; } _logger.LogDebug("AD user {Username} found", userName); var passwordResetResponse = await _userApiClient.ResetUserPasswordAsync(userName); _logger.LogDebug("AD user {Username} password has been reset", userName); var passwordResetNotificationRequest = AddNotificationRequestMapper.MapToPasswordResetNotification( $"{userProfile.FirstName} {userProfile.LastName}", passwordResetResponse.NewPassword, userProfile.Email); await _notificationApiClient.CreateNewNotificationAsync(passwordResetNotificationRequest); }