public static void SeedTestData(ModelBuilder modelBuilder)
        {
            Campaign               testCampaign         = Campaign.Create("TEST", "A test campaign");
            List <Contact>         testContacts         = CreateContacts();
            List <CampaignContact> testCampaignContacts = CreateCampaignContacts(testCampaign, testContacts);
            EmailTemplate          emailTemplate        = EmailTemplate.Create(testFrom, testSubject, testContent);
            CampaignSetting        campaignSetting      = CampaignSetting.Create(testCampaign.CampaignId, emailTemplate.EmailTemplateId, 1);

            campaignSetting.Active = true; // newly created campaign settings are set to inactive by default

            modelBuilder.Entity <Campaign>().HasData(testCampaign);
            modelBuilder.Entity <Contact>().HasData(testContacts);
            modelBuilder.Entity <CampaignContact>().HasData(testCampaignContacts);
            modelBuilder.Entity <EmailTemplate>().HasData(emailTemplate);
            modelBuilder.Entity <CampaignSetting>().HasData(campaignSetting);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CreateCampaignSettings(Guid campaignId, Guid templateId, int emailDay)
        {
            try
            {
                CampaignSetting campaignSetting = CampaignSetting.Create(campaignId, templateId, emailDay);

                _automailerContext.CampaignSettings.Add(campaignSetting);
                await _automailerContext.SaveChangesAsync();

                return(Ok(campaignSetting));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(Problem(ex.Message));
            }
        }