Kentico CMS 6.0 On-line Marketing Guide

Managing contact statuses

Managing contact statuses

Previous topic Next topic Mail us feedback on this topic!  

Managing contact statuses

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

The following example creates a contact status.

 

private bool CreateContactStatus()

{

  // Create new contact status object

  ContactStatusInfo newStatus = new ContactStatusInfo()

       {

           ContactStatusDisplayName = "My new status",

           ContactStatusName = "MyNewStatus",

           ContactStatusSiteID = CMSContext.CurrentSiteID

       };

 

  // Save the contact status

  ContactStatusInfoProvider.SetContactStatusInfo(newStatus);

 

  return true;

}

 

The following example gets and updates the contact status created by the example above.

 

private bool GetAndUpdateContactStatus()

{

  // Get the contact status

  ContactStatusInfo updateStatus = ContactStatusInfoProvider.GetContactStatusInfo("MyNewStatus", CMSContext.CurrentSiteName);

  if (updateStatus != null)

   {

      // Update a property

       updateStatus.ContactStatusDisplayName = updateStatus.ContactStatusDisplayName.ToLower();

 

      // Save the changes

      ContactStatusInfoProvider.SetContactStatusInfo(updateStatus);

 

      return true;

   }

 

  return false;

}

 

The following example gets and bulk updates multiple contact statuses specified by a WHERE condition.

 

private bool GetAndBulkUpdateContactStatuses()

{

  // Get the contact statuses dataset

  string where = "ContactStatusName LIKE N'MyNewStatus%'";

  InfoDataSet<ContactStatusInfo> statuses = ContactStatusInfoProvider.GetContactStatuses(where, null);

 

  if (!DataHelper.DataSourceIsEmpty(statuses))

   {

      foreach (ContactStatusInfo contactStatus in statuses)

       {

          // Update a property

           contactStatus.ContactStatusDisplayName = contactStatus.ContactStatusDisplayName.ToUpper();

 

          // Save the changes

          ContactStatusInfoProvider.SetContactStatusInfo(contactStatus);

       }

 

      return true;

   }

 

  return false;

}

 

The following example deletes the contact status created by the first example in this topic.

 

private bool DeleteContactStatus()

{

  // Get the contact status

  ContactStatusInfo deleteStatus = ContactStatusInfoProvider.GetContactStatusInfo("MyNewStatus", CMSContext.CurrentSiteName);

 

  if (deleteStatus != null)

   {

      // Delete the contact status

      ContactStatusInfoProvider.DeleteContactStatusInfo(deleteStatus);

 

      return true;

   }

 

  return false;

}