예제 #1
0
        Communication ICampaignEmailsCommand.GeneratePreview(CampaignEmail email, Guid campaignId)
        {
            // Get the campaign.

            var campaign = _campaignsQuery.GetCampaign(campaignId);

            if (campaign == null)
            {
                throw new ApplicationException("Cannot find the campaign with id '" + campaignId + "'.");
            }

            email.Properties.Add("Category", campaign.CommunicationCategoryId == null ? "Campaign" : _settingsQuery.GetCategory(campaign.CommunicationCategoryId.Value).Name);
            email.Properties.Add("IncludeUnsubscribe", true);

            var template = _campaignsQuery.GetTemplate(campaign.Id);

            if (template != null)
            {
                // Create an item template based on it.

                var templateContentItem = CreateTemplateContentItem(campaign, template);
                return(_emailsCommand.GeneratePreview(email, templateContentItem));
            }

            return(_emailsCommand.GeneratePreview(email));
        }
예제 #2
0
        public ActionResult EditTemplate(Guid id)
        {
            // Get the campaign.

            var campaign = _campaignsQuery.GetCampaign(id);

            if (campaign == null)
            {
                return(NotFound("campaign", "id", id));
            }

            var template = _campaignsQuery.GetTemplate(id) ?? new Template();

            var createdBy = _administratorsQuery.GetAdministrator(campaign.CreatedBy);

            return(View(new CampaignSummaryModel {
                Campaign = campaign, Template = template, CreatedBy = createdBy, IsReadOnly = IsReadOnly(campaign), CommunicationDefinitions = _settingsQuery.GetDefinitions(), CommunicationCategories = _settingsQuery.GetCategories()
            }));
        }
예제 #3
0
        protected void AssertCampaigns(Campaign[] expectedCampaigns, Template[] expectedTemplates)
        {
            // Get each individually.

            for (var index = 0; index < expectedCampaigns.Length; ++index)
            {
                Assert.AreNotEqual(DateTime.MinValue, expectedCampaigns[index].CreatedTime);
                AssertCampaign(expectedCampaigns[index], _campaignsQuery.GetCampaign(expectedCampaigns[index].Id));
                AssertTemplate(expectedTemplates[index], _campaignsQuery.GetTemplate(expectedCampaigns[index].Id));
            }

            // Get all.

            var campaigns = _campaignsQuery.GetCampaigns(null, new Range());

            Assert.AreEqual(expectedCampaigns.Length, campaigns.RangeItems.Count);
            for (var index = 0; index < expectedCampaigns.Length; ++index)
            {
                AssertCampaign(expectedCampaigns[index], campaigns.RangeItems[index]);
            }
        }