Exemplo n.º 1
0
        protected void CreateCampaigns(int start, int count, CampaignCategory category, out IList <Campaign> campaigns, out IList <Template> templates)
        {
            campaigns = new List <Campaign>();
            templates = new List <Template>();
            var createdStart = DateTime.Now.AddDays(-2);

            for (var index = start; index < start + count; ++index)
            {
                var name     = string.Format(CampaignNameFormat, index < 10 ? "00" + index : (index < 100 ? "0" + index : index.ToString(CultureInfo.InvariantCulture)));
                var campaign = new Campaign
                {
                    Id          = Guid.NewGuid(),
                    CreatedTime = createdStart.AddSeconds(index),
                    Name        = name,
                    Category    = category,
                };

                var template = new Template
                {
                    Subject = string.Format(TemplateSubjectFormat, index < 10 ? "00" + index : (index < 100 ? "0" + index : index.ToString(CultureInfo.InvariantCulture))),
                    Body    = string.Format(TemplateBodyFormat, index < 10 ? "00" + index : (index < 100 ? "0" + index : index.ToString(CultureInfo.InvariantCulture)))
                };

                _campaignsRepository.CreateCampaign(campaign);
                _campaignsRepository.CreateTemplate(campaign.Id, template);

                // Newest campaigns at start.

                campaigns.Insert(0, campaign);
                templates.Insert(0, template);
            }
        }
Exemplo n.º 2
0
        void ICampaignsCommand.CreateCampaign(Campaign campaign)
        {
            // Pre-process it.

            campaign.Prepare();
            campaign.Validate();

            // Create it.

            _repository.CreateCampaign(campaign);
        }
Exemplo n.º 3
0
        protected void CreateTestCampaign(int index, CampaignCategory category, CampaignStatus status, out Campaign campaign, out Template template)
        {
            campaign = new Campaign
            {
                Id          = Guid.NewGuid(),
                Name        = Format(CampaignNameFormat, index),
                CreatedTime = DateTime.Now.AddMinutes(index),
                Category    = category,
                Query       = null,
                Status      = status,
            };

            _repository.CreateCampaign(campaign);
            template = new Template
            {
                Subject = Format(TemplateSubjectFormat, index),
                Body    = Format(TemplateBodyFormat, index)
            };

            _repository.CreateTemplate(campaign.Id, template);
        }