public bool AddTemplate(NotificationTemplateInfo template, out string filePath)
 {
     filePath = string.Empty;
     try
     {
         filePath = GetFilePath(template);
         NotificationTemplateInfo copy = template.CopyAs <NotificationTemplateInfo>();
         Templates.AddTemplate(copy.Name, copy.Content);
         copy.Content = null;
         copy.Save(filePath);
         return(true);
     }
     catch (Exception ex)
     {
         Logger.AddEntry("Error adding template {0}: {1}", ex, template?.PropertiesToLine(), ex.Message);
         return(false);
     }
 }
Exemple #2
0
        protected void btnAdd_Command(object sender, CommandEventArgs args)
        {
            var template = Selection.SelectedItem.Clone(false);
            var children = Selection.SelectedItem.GetChildren();

            for (int i = 0; i < children.Count; i++)
            {
                CheckBox chkChildren = (CheckBox)rptChildren.Items[i].FindControl("chkChildren");
                if (chkChildren.Checked)
                {
                    children[i].Clone(true).AddTo(template);
                }
            }
            template.Title = txtTitle.Text;
            template[ContentTemplateRepository.TemplateDescription] = txtDescription.Text;
            Templates.AddTemplate(template);

            Response.Redirect("Default.aspx#" + tpTemplates.ClientID);
        }