Exemple #1
0
        protected override async Task Handle(SendDeletedPermissionsNotificationCommand request, CancellationToken cancellationToken)
        {
            var organisation = await _db.Value.AccountLegalEntities.IgnoreQueryFilters().SingleAsync(a => a.Id == request.AccountLegalEntityId, cancellationToken);

            await _client.SendEmailToAllProviderRecipients(request.Ukprn, new ProviderEmailRequest {
                TemplateId = TemplateId,
                Tokens     = new Dictionary <string, string> {
                    { "organisation_name", organisation.Name }
                }
            });
        }
        public async Task Handle(CohortAssignedToProviderEvent message, IMessageHandlerContext context)
        {
            try
            {
                _logger.LogInformation($"Received {nameof(CohortAssignedToProviderEvent)} for cohort {message?.CohortId}");
                var cohortSummary = await _mediator.Send(new GetCohortSummaryQuery(message.CohortId));

                if (cohortSummary.ChangeOfPartyRequestId.HasValue)
                {
                    return;
                }

                var emailRequest = BuildEmailRequest(cohortSummary);
                await _pasAccountApiClient.SendEmailToAllProviderRecipients(cohortSummary.ProviderId.Value, emailRequest).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"Send message to provider for cohort {message?.CohortId} failed");
                throw;
            }
        }
Exemple #3
0
        protected override async Task Handle(SendUpdatedPermissionsNotificationCommand request, CancellationToken cancellationToken)
        {
            var organisation = await _db.Value.AccountLegalEntities.SingleAsync(a => a.Id == request.AccountLegalEntityId, cancellationToken);

            var provider = await _db.Value.Providers.SingleAsync(p => p.Ukprn == request.Ukprn, cancellationToken);

            var permissionUpdatesTokens = GetPermissionsUpdatedTokens(request.PreviousOperations, request.GrantedOperations, organisation.Name);

            if (permissionUpdatesTokens.Any())
            {
                await _client.SendEmailToAllProviderRecipients(request.Ukprn, new ProviderEmailRequest {
                    TemplateId = TemplateId,
                    Tokens     = new Dictionary <string, string>
                    {
                        { "training_provider_name", provider.Name },
                        { "organisation_name", organisation.Name },
                    }
                    .Concat(permissionUpdatesTokens)
                    .ToDictionary(x => x.Key, x => x.Value)
                });
            }
        }
        public async Task Handle(SendEmailToProviderCommand message, IMessageHandlerContext context)
        {
            try
            {
                var providerEmailRequest = new ProviderEmailRequest
                {
                    TemplateId             = message.Template,
                    Tokens                 = message.Tokens,
                    ExplicitEmailAddresses = string.IsNullOrWhiteSpace(message.EmailAddress)
                        ? new List <string>()
                        : new List <string> {
                        message.EmailAddress
                    }
                };

                await _pasAccountApi.SendEmailToAllProviderRecipients(message.ProviderId, providerEmailRequest);
            }
            catch (Exception e)
            {
                _logger.LogError($"Error processing {nameof(SendEmailToProviderCommand)}", e);
                throw;
            }
        }
Exemple #5
0
        private Task SendEmails(long providerId, IList <ProviderAlertSummary> alertSummaries)
        {
            var alert = alertSummaries.First(m => m.ProviderId == providerId);

            var email = new ProviderEmailRequest
            {
                TemplateId = "ProviderAlertSummaryNotification2",
                Tokens     =
                    new Dictionary <string, string>
                {
                    { "total_count_text", alert.TotalCount.ToString() },
                    { "need_needs", alert.TotalCount > 1 ? "need" : "needs" },
                    { "changes_for_review", ChangesForReviewText(alert.ChangesForReview) },
                    { "mismatch_changes", GetMismatchText(alert.DataMismatchCount) },
                    {
                        "link_to_mange_apprenticeships",
                        $"{providerId}/apprentices/manage/all?RecordStatus=ChangesForReview&RecordStatus=IlrDataMismatch&RecordStatus=ChangeRequested"
                    }
                }
            };

            return(_providerAccountClient.SendEmailToAllProviderRecipients(providerId, email));
        }
 public async Task SendProviderEmailNotifications(long ukprn, ProviderEmailRequest request)
 {
     await _accountApiClient.SendEmailToAllProviderRecipients(ukprn, request);
 }