public async Task PublishAllTestTemplates() { foreach (var item in TEST_TEMPLATES) { var mailTemplate = await _mailTemplateHelper.FetchAsync(item, false); if (mailTemplate?.ID > 0) { await _mailTemplateRepository.SaveAsync(mailTemplate, mailTemplate.UserID.Value, TEST_USER_NAME, TEST_USER_EMAIL); await _mailTemplateRepository.PublishAsync(mailTemplate, mailTemplate.UserID.Value, TEST_USER_NAME, TEST_USER_EMAIL); } else { Assert.Fail($"Mailtemplate '{item}' wasn't found"); } } }
private async Task MailTemplatesList_ListAction(ComponentActionEventArgs e) { if (BtnDeleteSelected && wim.ChangedSearchGridItem != null) { var mailTemplateIDs = new List <int>(); foreach (var item in wim.ChangedSearchGridItem) { var mailTemplate = item as Data.MailTemplateList; mailTemplateIDs.Add(mailTemplate.ID); } var isSuccess = await _mailTemplateRepository.DeleteAsync(mailTemplateIDs); if (!isSuccess) { wim.Notification.AddError("Failed to delete the selected templates."); } var keyValues = new List <KeyValue>(); Context.Response.Redirect(wim.GetUrl(keyValues.ToArray())); } if (BtnPublish && await CanSaveAsync()) { var result = await _mailTemplateListRepository.FetchSingleByIdentifierAsync(Identifier); if (result != null && result.ID != Implement.ID) { await Notification.InsertOneAsync("Wim.Module.MailTemplate", $"Identifier {Identifier} is already in use."); } if (await _mailTemplateRepository.PublishAsync(Implement, wim.CurrentApplicationUser.ID, wim.CurrentApplicationUser.Displayname, wim.CurrentApplicationUser.Email)) { wim.CurrentVisitor.Data.Apply("wim.note", "Template is published", null); await wim.CurrentVisitor.SaveAsync(); Response.Redirect(wim.GetUrl(new KeyValue[] { new KeyValue { Key = "list", Value = wim.CurrentList.ID }, new KeyValue { Key = "item", Value = Implement.ID } })); } } if (BtnRevert && await _mailTemplateRepository.RevertAsync(Implement, wim.CurrentApplicationUser.ID, wim.CurrentApplicationUser.Displayname, wim.CurrentApplicationUser.Email)) { wim.Notification.AddNotificationAlert($"Template has been reverted to the published version", true); Response.Redirect(wim.GetUrl(new KeyValue[] { new KeyValue { Key = "list", Value = wim.CurrentList.ID }, new KeyValue { Key = "item", Value = Implement.ID } })); } }