Exemple #1
0
        private async Task NotifyCommitteeMembersAboutNewSuggestionAsync(CommitteeEntity committee, CommitteeSuggestion suggestion)
        {
            if (committee.Members == null || !committee.Members.Any())
            {
                return;
            }

            IList <string> membersEmails = committee.Members.Select(s => s.Email).ToList();

            var organizationName = await _organizationDbSet
                                   .Where(organization => organization.Id == committee.OrganizationId)
                                   .Select(organization => organization.ShortName)
                                   .FirstOrDefaultAsync();

            var committeesListUrl           = _appSettings.CommitteeSugestionUrl(organizationName);
            var userNotificationSettingsUrl = _appSettings.UserNotificationSettingsUrl(organizationName);
            var subject = string.Format(Resources.Common.CommitteeSuggestionEmailSubject, committee.Name);

            var emailTemplateViewModel = new CommitteeSuggestionEmailTemplateViewModel(userNotificationSettingsUrl,
                                                                                       committee.Name,
                                                                                       suggestion.Title,
                                                                                       suggestion.Description,
                                                                                       committeesListUrl);

            var body = _mailTemplate.Generate(emailTemplateViewModel, EmailPremiumTemplateCacheKeys.CommitteeSuggestion);

            await _mailingService.SendEmailAsync(new EmailDto(membersEmails, subject, body));
        }