示例#1
0
        protected void CreateTestCampaign(int index, out Campaign campaign, out Template template)
        {
            campaign = new Campaign
            {
                Name      = string.Format(CampaignNameFormat, index),
                CreatedBy = Guid.NewGuid(),
            };

            _campaignsCommand.CreateCampaign(campaign);

            template = new Template
            {
                Subject = string.Format(TemplateSubjectFormat, index),
                Body    = string.Format(TemplateBodyFormat, index)
            };
            _campaignsCommand.CreateTemplate(campaign.Id, template);
        }
示例#2
0
        public ActionResult PostEditTemplate(Guid id, string subject, string body)
        {
            // Check that the campaign exists.

            var campaign = _campaignsQuery.GetCampaign(id);

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

            Template template = null;

            try
            {
                template = _campaignsQuery.GetTemplate(id);
                if (template == null)
                {
                    template = new Template
                    {
                        Subject = subject,
                        Body    = body,
                    };
                    _campaignsCommand.CreateTemplate(id, template);
                }
                else
                {
                    // Update it with the new values.

                    template.Subject = subject;
                    template.Body    = body;
                    _campaignsCommand.UpdateTemplate(id, template);
                }

                return(RedirectToRoute(CampaignsRoutes.EditTemplate, new { id }));
            }
            catch (UserException ex)
            {
                ModelState.AddModelError(ex, new StandardErrorHandler());
            }

            // Show the user the errors.

            return(View(template));
        }
示例#3
0
        protected void CreateCampaign(int index, CampaignCategory category, string query, out Campaign campaign, out Template template)
        {
            campaign = new Campaign
            {
                Id                      = Guid.NewGuid(),
                Name                    = string.Format(CampaignNameFormat, index),
                CreatedBy               = Guid.NewGuid(),
                CreatedTime             = DateTime.Now.AddMinutes(index),
                Category                = category,
                CommunicationCategoryId = _settingsQuery.GetCategory("Campaign").Id,
                Query                   = query,
            };

            _campaignsCommand.CreateCampaign(campaign);

            template = new Template
            {
                Subject = string.Format(TemplateSubjectFormat, index),
                Body    = string.Format(TemplateBodyFormat, index)
            };
            _campaignsCommand.CreateTemplate(campaign.Id, template);
        }