// Saves the subscriber SubscriberInfoProvider.SetSubscriberInfo(newSubscriber);
returntrue; }
The following example gets and updates a subscriber.
privatebool GetAndUpdateSubscriber() { // Gets the subscriber SubscriberInfo updateSubscriber = SubscriberInfoProvider.GetSubscriberInfo("subscriber@localhost.local", CMSContext.CurrentSiteID); if (updateSubscriber != null) { // Updates the properties updateSubscriber.SubscriberFullName = updateSubscriber.SubscriberFullName.ToLower();
// Saves the changes SubscriberInfoProvider.SetSubscriberInfo(updateSubscriber);
returntrue; }
returnfalse; }
The following example gets and bulk updates subscribers.
privatebool GetAndBulkUpdateSubscribers() { // Prepares the parameters string where = "SubscriberEmail LIKE N'subscriber@localhost.local%'";
// Gets the data DataSet subscribers = SubscriberInfoProvider.GetSubscribers(where, null); if (!DataHelper.DataSourceIsEmpty(subscribers)) { // Loops through the items foreach (DataRow subscriberDr in subscribers.Tables[0].Rows) { // Creates an object from the DataRow SubscriberInfo modifySubscriber = newSubscriberInfo(subscriberDr);
// Updates the properties modifySubscriber.SubscriberFullName = modifySubscriber.SubscriberFullName.ToUpper();
// Saves the changes SubscriberInfoProvider.SetSubscriberInfo(modifySubscriber); }
returntrue; }
returnfalse; }
The following example subscribes a subscriber to newsletter.
privatebool SubscribeToNewsletter() { // Gets the subscriber and newsletter SubscriberInfo subscriber = SubscriberInfoProvider.GetSubscriberInfo("subscriber@localhost.local", CMSContext.CurrentSiteID); NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewStaticNewsletter", CMSContext.CurrentSiteID);
if ((subscriber != null) && (newsletter != null)) { // Subscribes to 'My new static newsletter' SubscriberInfoProvider.Subscribe(subscriber.SubscriberID, newsletter.NewsletterID, DateTime.Now);
returntrue; }
returnfalse; }
The following example unsubscribes a subscriber from newsletter.
privatebool UnsubscribeFromNewsletter() { // Gets the subscriber and newsletter SubscriberInfo subscriber = SubscriberInfoProvider.GetSubscriberInfo("subscriber@localhost.local", CMSContext.CurrentSiteID); NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewStaticNewsletter", CMSContext.CurrentSiteID);
if ((subscriber != null) && (newsletter != null)) { // Unubscribes from 'My new static newsletter' SubscriberInfoProvider.Unsubscribe(subscriber.SubscriberID, newsletter.NewsletterID);