Ejemplo n.º 1
0
        public async Task <bool> ImportEmailToListAsync(int userId, EmailReminder emailReminder)
        {
            if (emailReminder == null)
            {
                throw new ArgumentNullException(nameof(emailReminder));
            }

            var alreadySubscribed = await _emailReminderRepository
                                    .ExistsEmailSourceAsync(emailReminder.Email, emailReminder.SignUpSource);

            if (!alreadySubscribed)
            {
                await _emailReminderRepository.AddAsync(userId,
                                                        new EmailReminder
                {
                    CreatedAt    = emailReminder.CreatedAt,
                    Email        = emailReminder.Email,
                    LanguageId   = emailReminder.LanguageId,
                    SignUpSource = emailReminder.SignUpSource
                });

                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public void StartReminders()
        {
            string        userId   = User.Identity.GetUserId();
            EmailReminder reminder = new EmailReminder();

            reminder.RunReminders(userId);
        }
        public async Task SendBulkAsync(EmailReminder emailReminder,
                                        int emailTemplateId,
                                        int siteId)
        {
            var site = await _siteRepository.GetByIdAsync(siteId);

            var template = await _emailTemplateRepository.GetByIdAsync(emailTemplateId);

            var bodyText = template.BodyText
                           .Replace("{{Email}}", emailReminder.Email);
            var bodyHtml = template.BodyHtml
                           .Replace("{{Email}}", emailReminder.Email);

            if (!string.IsNullOrEmpty(emailReminder.Email))
            {
                await SendEmailAsync(site,
                                     emailReminder.Email,
                                     template.Subject,
                                     bodyText,
                                     bodyHtml,
                                     providedFromName : template.FromName,
                                     providedFromEmail : template.FromAddress);
            }
            else
            {
                _logger.LogError("Unable to send email to address {EmailAddress} for template id {TemplateId}: no email address configured.",
                                 emailReminder.Email,
                                 emailTemplateId);
            }
        }