Exemple #1
0
        private IEnumerable <EmailMessage> GetEmailMessages(
            long templateId,
            IEnumerable <RecipientData> recipients,
            EventDataForEntity data,
            IReadOnlyDictionary <string, FileHolder[]> files,
            long?userId,
            EventType type)
        {
            var application = _applications.Get(data.EntityId);

            foreach (var recipient in recipients)
            {
                var localization = _templates.GetLocalization(templateId, recipient.Culture);

                if (localization == null)
                {
                    continue;
                }

                var filesToSend = GetFiles(type, recipient, files);

                yield return(GetEmailMessage(
                                 recipient.Email,
                                 recipient.Culture,
                                 localization,
                                 application,
                                 data.Data,
                                 type,
                                 filesToSend,
                                 userId));
            }
        }
		private Dictionary<string, EmailTemplateLocalizationData> GetLocalizationData(
			EventDataForEntity eventData,
			IEnumerable<string> languages,
			long templateId)
		{
			return languages.ToDictionary(
				x => x,
				language =>
				{
					var template = _templates.GetLocalization(templateId, language);

					var localizedData = _localizedHelper.Get(language, eventData);

					return new EmailTemplateLocalizationData
					{
						IsBodyHtml = template.IsBodyHtml,
						Subject = _textBuilder.GetText(template.Subject, language, localizedData),
						Body = _textBuilder.GetText(template.Body, language, localizedData)
					};
				});
		}