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); }
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)); }
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); }