Kentico CMS 6.0 Developer's Guide

Managing issues

Managing issues

Previous topic Next topic Mail us feedback on this topic!  

Managing issues

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Arrow


API examples for newer versions


Please visit the latest API Examples documentation to view API examples for newer versions of Kentico.



The following example creates a static issue.

 

private bool CreateStaticIssue()
{
  // Get the newsletter
  Newsletter newsletter = NewsletterProvider.GetNewsletter("MyNewStaticNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Create new static issue object
      Issue newIssue = new Issue();

 
      // Set the properties
       newIssue.IssueSubject = "My new static issue";
       newIssue.IssueNewsletterID = newsletter.NewsletterID;
       newIssue.IssueSiteID = CMSContext.CurrentSiteID;
       newIssue.IssueText = "<?xml version=\"1.0\" encoding=\"utf-16\"?><content><region id=\"content\">Issue text</region></content>";
       newIssue.IssueUnsubscribed = 0;
       newIssue.IssueSentEmails = 0;
       newIssue.IssueTemplateID = newsletter.NewsletterTemplateID;
       newIssue.IssueShowInNewsletterArchive = false;

 
      // Save the static issue
      IssueProvider.SetIssue(newIssue);

 
      return true;
   }

 
  return false;
}

 

The following example gets and updates a static issue.

 

private bool GetAndUpdateStaticIssue()
{
  // Get the newsletter
  Newsletter newsletter = NewsletterProvider.GetNewsletter("MyNewStaticNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Prepare the parameters
      string where = "IssueNewsletterID = " + newsletter.NewsletterID;

 
      // Get the data
      DataSet issues = IssueProvider.GetIssues(where, null);

 
      if (!DataHelper.DataSourceIsEmpty(issues))
       {
          // Create object from DataRow
          Issue updateIssue = new Issue(issues.Tables[0].Rows[0]);

 
          if (updateIssue != null)
           {
              // Update the properties
               updateIssue.IssueSubject = updateIssue.IssueSubject.ToLower();

 
              // Save the changes
              IssueProvider.SetIssue(updateIssue);

 
              return true;
           }
       }
   }
  return false;
}

 

The following example gets and bulk updates static issues.

 

private bool GetAndBulkUpdateStaticIssues()

{
  // Get the newsletter
  Newsletter newsletter = NewsletterProvider.GetNewsletter("MyNewStaticNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Prepare the parameters
      string where = "IssueNewsletterID = " + newsletter.NewsletterID;

 
      // Get the data
      DataSet issues = IssueProvider.GetIssues(where, null);
      if (!DataHelper.DataSourceIsEmpty(issues))
       {
          // Loop through the individual items
          foreach (DataRow issueDr in issues.Tables[0].Rows)
           {
              // Create object from DataRow
              Issue modifyIssue = new Issue(issueDr);

 
              // Update the properties
               modifyIssue.IssueSubject = modifyIssue.IssueSubject.ToUpper();

 
              // Save the changes
              IssueProvider.SetIssue(modifyIssue);
           }

 
          return true;
       }
   }

 
  return false;
}

 

The following example creates a dynamic issue.

 

private bool CreateDynamicIssue()
{
  // Get the newsletter
  Newsletter newsletter = NewsletterProvider.GetNewsletter("MyNewDynamicNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Generate dynamic issue
      EmailQueueManager.GenerateDynamicIssue(newsletter.NewsletterID);

 
      return true;
   }

 
  return false;
}

 

The following example gets and updates a dynamic issue.

 

private bool GetAndUpdateDynamicIssue()
{
  // Get the newsletter
  Newsletter newsletter = NewsletterProvider.GetNewsletter("MyNewDynamicNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Prepare the parameters
      string where = "IssueNewsletterID = " + newsletter.NewsletterID;

 
      // Get the data
      DataSet issues = IssueProvider.GetIssues(where, null);

 
      if (!DataHelper.DataSourceIsEmpty(issues))
       {
          // Create object from DataRow
          Issue updateIssue = new Issue(issues.Tables[0].Rows[0]);

 
          if (updateIssue != null)
           {
              // Update the properties
               updateIssue.IssueSubject = updateIssue.IssueSubject.ToLower();

 
              // Save the changes
              IssueProvider.SetIssue(updateIssue);

 
              return true;
           }
       }
   }
  return false;
}

 

The following example gets and bulk updates dynamic issues.

 

private bool GetAndBulkUpdateDynamicIssues()
{
  // Get the newsletter
  Newsletter newsletter = NewsletterProvider.GetNewsletter("MyNewDynamicNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Prepare the parameters
      string where = "IssueNewsletterID = " + newsletter.NewsletterID;

 
      // Get the data
      DataSet issues = IssueProvider.GetIssues(where, null);
      if (!DataHelper.DataSourceIsEmpty(issues))
       {
          // Loop through the individual items
          foreach (DataRow issueDr in issues.Tables[0].Rows)
           {
              // Create object from DataRow
              Issue modifyIssue = new Issue(issueDr);

 
              // Update the properties
               modifyIssue.IssueSubject = modifyIssue.IssueSubject.ToUpper();

 
              // Save the changes
              IssueProvider.SetIssue(modifyIssue);
           }

 
          return true;
       }
   }
  return false;
}

 

The following example deletes a dynamic issue.

 

private bool DeleteDynamicIssue()
{
  // Get the newsletter
  Newsletter newsletter = NewsletterProvider.GetNewsletter("MyNewDynamicNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Prepare the parameters
      string where = "IssueNewsletterID = " + newsletter.NewsletterID;

 
      // Get the data
      DataSet issues = IssueProvider.GetIssues(where, null);

 
      if (!DataHelper.DataSourceIsEmpty(issues))
       {
          // Create object from DataRow
          Issue deleteIssue = new Issue(issues.Tables[0].Rows[0]);

 
          // Delete the dynamic issue
          IssueProvider.DeleteIssue(deleteIssue);

 
          return (deleteIssue != null);
       }
   }
  return false;
}

 

The following example deletes a static issue.

 

private bool DeleteStaticIssue()
{
  // Get the newsletter
  Newsletter newsletter = NewsletterProvider.GetNewsletter("MyNewStaticNewsletter", CMSContext.CurrentSiteID);

 
  if (newsletter != null)
   {
      // Prepare the parameters
      string where = "IssueNewsletterID = " + newsletter.NewsletterID;

 
      // Get the data
      DataSet issues = IssueProvider.GetIssues(where, null);

 
      if (!DataHelper.DataSourceIsEmpty(issues))
       {
          // Create object from DataRow
          Issue deleteIssue = new Issue(issues.Tables[0].Rows[0]);

 

          // Delete the static issue
          IssueProvider.DeleteIssue(deleteIssue);

 
          return (deleteIssue != null);
       }
   }
  return false;
}