public async Task SendProviderTransferRejectedCommitmentEditNotification(CommitmentView commitment)
        {
            if (!_configuration.CommitmentNotification.SendEmail)
            {
                Logger.Info("Sending email notifications disabled by config.");
                return;
            }

            var emailMessage = new EmailMessage
            {
                TemplateId = "ProviderTransferRejectedCommitmentEditNotification",
                Tokens     = new Dictionary <string, string>
                {
                    { "EmployerName", commitment.LegalEntityName },
                    { "CohortRef", commitment.Reference }
                }
            };

            Logger.Info($"Sending email to all provider recipients for Provider {commitment.ProviderId}, template {emailMessage.TemplateId}");

            await _providerEmailService.SendEmailToAllProviderRecipients(
                commitment.ProviderId.GetValueOrDefault(),
                commitment.ProviderLastUpdateInfo?.EmailAddress ?? string.Empty,
                emailMessage);
        }
        private async Task SendNotification(CommitmentView commitment, SubmitCommitmentCommand message)
        {
            _logger.Info($"Sending notification for commitment {commitment.Id} to providers with ukprn {commitment.ProviderId}");

            var tokens = new Dictionary <string, string> {
                { "cohort_reference", commitment.Reference }
            };

            string templateId;

            switch (commitment.AgreementStatus)
            {
            case AgreementStatus.NotAgreed when commitment.TransferSender != null:
                templateId = "TransferProviderCommitmentNotification";
                tokens["receiving_employer"] = commitment.LegalEntityName;
                break;

            case AgreementStatus.NotAgreed:
                templateId     = "ProviderCommitmentNotification";
                tokens["type"] = message.LastAction == LastAction.Approve ? "approval" : "review";
                break;

            case AgreementStatus.ProviderAgreed when commitment.TransferSender != null && message.LastAction == LastAction.Approve:
                templateId      = "TransferPendingFinalApproval";
                tokens["ukprn"] = commitment.ProviderId.ToString();
                tokens["receiving_employer"] = commitment.LegalEntityName;
                break;

            default:
                templateId = "ProviderCohortApproved";
                break;
            }

            var emailMessage = new EmailMessage
            {
                TemplateId = templateId,
                Tokens     = tokens
            };

            await _providerEmailService.SendEmailToAllProviderRecipients(
                commitment.ProviderId.GetValueOrDefault(),
                commitment.ProviderLastUpdateInfo?.EmailAddress ?? string.Empty,
                emailMessage);
        }