private int GetMarketableRecipientsCount()
 {
     return(mIssue
            .GetRecipientsProvider()
            .GetMarketableRecipients()
            .Count);
 }
    private string GetPreviewScriptForCampaign(IssueInfo issue, NewsletterInfo newsletter, IssueHelper issueHelper)
    {
        string currentSiteName = SiteContext.CurrentSiteName;

        var output     = new StringBuilder();
        var recipients = issue.GetRecipientsProvider()
                         .GetMarketableRecipients()
                         .TopN(MAX_PREVIEW_SUBSCRIBERS)
                         .ToList();

        if (!recipients.Any())
        {
            return(InitializePreviewScriptForZeroSubscribers(issue, GetPreviewSubject(issue, newsletter, issueHelper, null, currentSiteName)));
        }

        output.AppendLine(InitializePreviewScript(issue, recipients.Count));

        for (int index = 0; index < recipients.Count; index++)
        {
            var recipient = recipients[index];

            var dummySubscriber = new SubscriberInfo
            {
                SubscriberFirstName = recipient.ContactFirstName,
                SubscriberLastName  = recipient.ContactLastName,
                SubscriberEmail     = recipient.ContactEmail
            };

            output.AppendFormat("guid[{0}] = '{1}';", index, recipient.ContactGUID);
            output.AppendFormat("email[{0}] = '{1}';", index, recipient.ContactEmail);
            output.AppendFormat("subject[{0}] = {1};", index, ScriptHelper.GetString(HTMLHelper.HTMLEncode(GetPreviewSubject(issue, newsletter, issueHelper, dummySubscriber, currentSiteName))));
        }

        return(output.ToString());
    }
    private void InitializeSubscribersForCampaign(IssueInfo issue, NewsletterInfo newsletter)
    {
        var recipients = issue.GetRecipientsProvider()
                         .GetMarketableRecipients()
                         .TopN(MAX_PREVIEW_SUBSCRIBERS)
                         .ToList();

        if (recipients.Count > 0)
        {
            for (int index = 0; index < recipients.Count; index++)
            {
                var recipient   = recipients[index];
                var subscriber  = recipient.ToContactSubscriber();
                var emailViewer = new EmailViewer(issue, newsletter, subscriber, true);

                emails.Add(HttpUtility.UrlEncode(recipient.ContactEmail));
                subjects.Add(GetEncodedSubscriberSubject(emailViewer));
                preheaders.Add(GetEncodedSubscriberPreheader(emailViewer));
                drpSubscribers.Items.Add(new ListItem(recipient.ContactEmail, index.ToString()));
            }
        }
        else
        {
            DisableSubscribersDropDownList();

            var emailViewer = new EmailViewer(issue, newsletter, null, true);

            InitializeZeroSubscribers(emailViewer.GetSubject(), emailViewer.GetPreheader());
        }
    }