Example #1
0
        public async Task <string> RunOrchestrator(
            [OrchestrationTrigger] IDurableOrchestrationContext context)
        {
            var    vm = context.GetInput <ArticleViewModel>();
            string id = await context.CallActivityAsync <string>(ConfirmationTask.CreateArticle, vm);

            var vmUpdate = ArticleUpdateViewModel.Create(vm);

            vmUpdate.Id = id;
            var activateSendMail = new ActivateArticleSendMail {
                Data = vmUpdate, InstanceId = context.InstanceId
            };
            await context.CallActivityAsync(ConfirmationTask.SendMailArticle, activateSendMail);

            await HumanInteractionArticle(context, vmUpdate);

            return(id);
        }
Example #2
0
        public async Task ConfirmArticle([ActivityTrigger] ActivateArticleSendMail activateSendMail,
                                         [SendGrid(ApiKey = "SendGridConnections:ApiKey")] IAsyncCollector <SendGridMessage> messageCollector,
                                         ILogger log)
        {
            var             articleData = activateSendMail.Data;
            SendGridMessage message     = new SendGridMessage();

            message.SetFrom(new EmailAddress(sendGridSettings.From));
            message.AddTos(adminSettings.GetMails().Select(x => new EmailAddress(x)).ToList());
            message.SetSubject($"New Article submitted: {articleData.Name}");
            message.SetTemplateId(sendGridSettings.TemplateArticleId);
            message.SetTemplateData(new MailArticleTemplateData
            {
                confirmurl         = adminSettings.GetConfirmationArticleLink(activateSendMail.InstanceId, true),
                aborturl           = adminSettings.GetConfirmationArticleLink(activateSendMail.InstanceId, false),
                articlename        = articleData.Name,
                articleurl         = articleData.Url.ToString(),
                articlepublishdate = articleData.PublishDate,
                articleauthors     = articleData.Authors.Select(t => new PersonTemplate {
                    name = t.Name, surname = t.Surname
                }).ToList()
            });
            await messageCollector.AddAsync(message);
        }