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); }