public async Task <ICollection <PreviewModel> > Handle(GetManyRequest request, CancellationToken cancellationToken)
        {
            var filter = request.Filter.ToDto();
            var dtos   = await fTemplateRepository.GetAsync(filter, cancellationToken);

            return(dtos.ToPreview());
        }
        public async Task <DetailModel> Handle(GetRequest request, CancellationToken cancellationToken)
        {
            var user = await fTemplateRepository.GetAsync(request.TemplateId, cancellationToken);

            if (user is null)
            {
                throw new NotFoundException($"Email template with ID '{request.TemplateId}' does not exist.");
            }

            return(user.ToDetail());
        }
        public async Task <IEmail> RenderEmailAsync(IEmailData emailData)
        {
            var emailModel = new EmailModel
            {
                CampaignId = emailData.CampaignId,
                TemplateId = emailData.TemplateId,
                To         = emailData.To,
                Subject    = emailData.Subject,
                Body       = await _cache.GetOrCreate(CacheKey(emailData.CampaignId), e => BuildEngine(emailData.CampaignId))
                             .CompileRenderAsync(emailData.TemplateId, emailData.Data),
                Attachments = emailData.Attachments,
            };

            if (string.IsNullOrWhiteSpace(emailData.Subject))
            {
                emailModel.Subject = (await _templateRepository.GetAsync(emailData.CampaignId, emailData.TemplateId)).Subject;
            }

            return(emailModel);
        }
Exemple #4
0
 public async override Task <RazorLightProjectItem> GetItemAsync(string templateId)
 {
     return(new AzureTableRazorLightProjectItem(await _templateRepository.GetAsync(_campaignId, templateId)));
 }