public async Task Handle(TransferRequestRejectedEvent message, IMessageHandlerContext context) { var cohortSummary = await _mediator.Send(new GetCohortSummaryQuery(message.CohortId)); var cohortReference = _encodingService.Encode(cohortSummary.CohortId, EncodingType.CohortReference); var sendEmailToEmployerCommand = new SendEmailToEmployerCommand(cohortSummary.AccountId, "SenderRejectedCommitmentEmployerNotification", new Dictionary <string, string> { { "employer_name", cohortSummary.LegalEntityName }, { "cohort_reference", cohortReference }, { "sender_name", cohortSummary.TransferSenderName }, { "employer_hashed_account", _encodingService.Encode(cohortSummary.AccountId, EncodingType.AccountId) }, }, cohortSummary.LastUpdatedByEmployerEmail); var sendEmailToProviderCommand = new SendEmailToProviderCommand(cohortSummary.ProviderId.Value, "SenderRejectedCommitmentProviderNotification", new Dictionary <string, string> { { "cohort_reference", cohortReference }, { "ukprn", cohortSummary.ProviderId.Value.ToString() }, }, cohortSummary.LastUpdatedByProviderEmail); await Task.WhenAll( context.Send(sendEmailToProviderCommand, new SendOptions()), context.Send(sendEmailToEmployerCommand, new SendOptions()) ); }
private async Task NotifyProvider(long providerId, long apprenticeshipId, string employerName, string apprenticeName, DateTime stopDate) { var sendEmailToProviderCommand = new SendEmailToProviderCommand(providerId, StopNotificationEmailTemplate, new Dictionary <string, string> { { "EMPLOYER", employerName }, { "APPRENTICE", apprenticeName }, { "DATE", stopDate.ToString("dd/MM/yyyy") }, { "URL", $"{providerId}/apprentices/manage/{_encodingService.Encode(apprenticeshipId, EncodingType.ApprenticeshipId)}/details" } }); await _nserviceBusContext.Send(sendEmailToProviderCommand); }
private SendEmailToProviderCommand BuildEmailToProviderCommand(Apprenticeship apprenticeship, DateTime resumeDate) { var sendEmailToProviderCommand = new SendEmailToProviderCommand(apprenticeship.Cohort.ProviderId, "ProviderApprenticeshipResumeNotification", new Dictionary <string, string> { { "EMPLOYER", apprenticeship.Cohort.AccountLegalEntity.Name }, { "APPRENTICE", $"{apprenticeship.FirstName} {apprenticeship.LastName}" }, { "DATE", resumeDate.ToString("dd/MM/yyyy") }, { "URL", $"{apprenticeship.Cohort.ProviderId}/apprentices/manage/{_encodingService.Encode(apprenticeship.Id, EncodingType.ApprenticeshipId)}/details" } }); return(sendEmailToProviderCommand); }
public SendEmailToProviderCommandHandlerTestsFixture() { _autoFixture = new Fixture(); ProviderId = _autoFixture.Create <long>(); TemplateId = _autoFixture.Create <string>(); ExplicitEmailAddress = _autoFixture.Create <string>(); Tokens = _autoFixture.Create <Dictionary <string, string> >(); Command = new SendEmailToProviderCommand(ProviderId, TemplateId, Tokens, null); MessageHandlerContext = new Mock <IMessageHandlerContext>(); Logger = new FakeLogger <SendEmailToProviderCommandHandler>(); PasAccountApiClient = new Mock <IPasAccountApiClient>(); PasAccountApiClient.Setup(x => x.SendEmailToAllProviderRecipients(It.IsAny <long>(), It.IsAny <ProviderEmailRequest>(), It.IsAny <CancellationToken>())); Handler = new SendEmailToProviderCommandHandler(PasAccountApiClient.Object, Logger); }
public SendEmailToProviderCommandHandlerTestsFixture SetupNullMessage() { Command = null; return(this); }
public SendEmailToProviderCommandHandlerTestsFixture SetExplicitEmailAddress() { Command = new SendEmailToProviderCommand(ProviderId, TemplateId, Tokens, ExplicitEmailAddress); return(this); }