Example #1
0
        private async Task SendNotifications(CommitmentView commitment, Commitments.Api.Types.TransferApprovalStatus newTransferApprovalStatus)
        {
            //todo: we should probably also check this in EmployerEmailNotificationService
            // (ProviderEmailNotificationService uses ProviderEmailService, which checks it)
            // or in defaultregistry we could supply no-op implementations for XxxEmailNotificationService when SendEmail is disabled
            if (!_configuration.CommitmentNotification.SendEmail)
            {
                _logger.Info("Sending email notifications disabled by config.");
                return;
            }

            var providerNotifyTask = _providerEmailNotificationService.SendSenderApprovedOrRejectedCommitmentNotification(commitment, newTransferApprovalStatus);
            var employerNotifyTask = _employerEmailNotificationService.SendSenderApprovedOrRejectedCommitmentNotification(commitment, newTransferApprovalStatus);

            await Task.WhenAll(providerNotifyTask, employerNotifyTask);
        }
Example #2
0
 private SendNotificationCommand BuildNotificationCommand(string emailAddress, Commitments.Api.Types.TransferApprovalStatus transferApprovalStatus, RecipientType recipientType, Dictionary <string, string> tokens)
 {
     return(new SendNotificationCommand
     {
         Email = new Email
         {
             RecipientsAddress = emailAddress,
             TemplateId = GenerateSenderApprovedOrRejectedTemplateId(transferApprovalStatus, recipientType),
             ReplyToAddress = "*****@*****.**",
             Subject = "x",
             SystemId = "x",
             Tokens = tokens
         }
     });
 }
        public async Task SendSenderApprovedOrRejectedCommitmentNotification(CommitmentView commitment, Commitments.Api.Types.TransferApprovalStatus newTransferApprovalStatus)
        {
            if (!_configuration.CommitmentNotification.SendEmail)
            {
                Logger.Info("Sending email notifications disabled by config.");
                return;
            }

            Logger.Info($"Sending notification to provider {commitment.ProviderId} that sender has {newTransferApprovalStatus} cohort {commitment.Id}");

            var tokens = new Dictionary <string, string>
            {
                { "cohort_reference", commitment.Reference },
                { "ukprn", commitment.ProviderId.ToString() }
            };

            await _providerEmailService.SendEmailToAllProviderRecipients(
                commitment.ProviderId.GetValueOrDefault(),
                commitment.ProviderLastUpdateInfo?.EmailAddress ?? string.Empty,
                new EmailMessage
            {
                TemplateId = GenerateSenderApprovedOrRejectedTemplateId(newTransferApprovalStatus, RecipientType.Provider),
                Tokens     = tokens
            });
        }
Example #4
0
        public async Task SendSenderApprovedOrRejectedCommitmentNotification(CommitmentView commitment, Commitments.Api.Types.TransferApprovalStatus newTransferApprovalStatus)
        {
            var email = commitment.EmployerLastUpdateInfo?.EmailAddress;

            if (string.IsNullOrWhiteSpace(email))
            {
                Logger.Info($"No email associated with employer, skipping notification of employer id {commitment.EmployerAccountId} that sender has {newTransferApprovalStatus} cohort id {commitment.Id}");
                return;
            }

            Logger.Info($"Sending email notification to {email} of employer id {commitment.EmployerAccountId} that sender has {newTransferApprovalStatus} cohort id {commitment.Id}");

            var tokens = new Dictionary <string, string>
            {
                { "cohort_reference", commitment.Reference },
                { "employer_name", commitment.LegalEntityName },
                { "sender_name", commitment.TransferSender.Name },
                { "employer_hashed_account", HashingService.HashValue(commitment.EmployerAccountId) }
            };

            var notificationCommand = BuildNotificationCommand(email, newTransferApprovalStatus, RecipientType.Employer, tokens);
            await _mediator.SendAsync(notificationCommand);
        }
Example #5
0
 protected string GenerateSenderApprovedOrRejectedTemplateId(Commitments.Api.Types.TransferApprovalStatus transferApprovalStatus, RecipientType recipientType)
 {
     return($"Sender{transferApprovalStatus}Commitment{recipientType}Notification");
 }