public CampaignVM GetCampaign(int campaignId) { CampaignService campaignService = new CampaignService(); var campaign = campaignService.GetCampaign(campaignId); CampaignAdapter adapter = new CampaignAdapter(); return adapter.GetVMFromCampaign(campaign); }
public List<CampaignVM> GetApprovalCampaigns() { List<CampaignVM> campaignVMList = new List<CampaignVM>(); CampaignService campaignService = new CampaignService(); int departmentId = UserModule.GetUsersDepartment(); var campaigns = campaignService.GetApprovalCampaigns(departmentId); CampaignAdapter adapter = new CampaignAdapter(); foreach (var campaign in campaigns) { campaignVMList.Add(adapter.GetVMFromCampaign(campaign)); } return campaignVMList; }
public bool RejectCampaign(int campaignId) { CampaignService campaignService = new CampaignService(); return campaignService.UpdateCampaignStatus(campaignId, CampaignStatus.Rejected); }
public IEnumerable<Sms> GetCampaignSmses(int campaignId, MessageStatus status = MessageStatus.All) { CampaignService campaignService = new CampaignService(); return campaignService.GetCampaignSmses(campaignId, status); }
public bool ApproveCampaign(int campaignId) { CampaignService campaignService = new CampaignService(); return campaignService.UpdateCampaignStatus(campaignId, CampaignStatus.Approved); }
public bool DeleteCampaign(int campaignId) { CampaignService campaignService = new CampaignService(); return campaignService.DeleteCampaign(campaignId); }
public bool StopCampaign(int campaignId) { CampaignService campaignService = new CampaignService(); return campaignService.UpdateCampaignStatus(campaignId, CampaignStatus.Stopped); }
public void UpdateCampaignFile(int campaignId) { CampaignService campaignService = new CampaignService(); var campaign = campaignService.GetCampaign(campaignId); var newFileName = "camp" + campaign.Id + Path.GetExtension(campaign.FileName); File.Move(GetFileName(campaign.FileName), GetFileName(newFileName)); campaign.FileName = newFileName; campaignService.UpdateCampaign(campaign); }
public bool SendTestCampaign(int campaignId, string recepient) { CampaignService campaignService = new CampaignService(); var campaign = campaignService.GetCampaign(campaignId); var user = new UserService().GetUser(campaign.CreatedBy); bool response = false; if (campaign.TypeId == (int)CampaignType.SMS) { SmsModule smsModule = new SmsModule(user.SmsUsername, user.SmsPassword); response = smsModule.SendSMS(recepient, campaign.ContentTemplate); } else { EmailModule emailModule = new EmailModule(user.EmailUsername, user.EmailPassword); response = emailModule.SendEmail(user.Name, recepient, "", "", campaign.SubjectTemplate, campaign.ContentTemplate); } return response; }
public bool ScheduleCampaign(int campaignId, DateTime scheduledDate) { CampaignService campaignService = new CampaignService(); return campaignService.UpdateCampaignStatus(campaignId, CampaignStatus.Scheduled, scheduledDate); }
public int SaveCampaign(CampaignReport report) { try { var campaignVM = report.Campaign; CampaignService campaignService = new CampaignService(); var campaign = new CampaignAdapter().GetCampaignFromVM(campaignVM); campaign.DepartmentId = UserModule.GetUsersDepartment(); if (campaign.Id == 0) campaign.Id = campaignService.SaveCampaign(campaign); else { campaignService.ReCreateCampaign(campaign, GetCampaign(campaign.Id).TypeId); } if (campaignVM.TypeId == (int)CampaignType.Email) { List<Email> emailList = new List<Email>(); foreach (var row in report.ExcelRows) { var recipient = ReplaceContentWithValue(row, campaignVM.RecipientField); Email email = new Email { Body = ReplaceContentWithValue(row, campaignVM.Content), CampaignId = campaign.Id, Id = 0, StatusId = (int)MessageStatus.New, StatusDate = DateTime.Now, Subject = ReplaceContentWithValue(row, campaignVM.Subject), ToAddress = recipient }; emailList.Add(email); } campaignService.SaveCampaignEmails(emailList); } else { List<Sms> smsList = new List<Sms>(); foreach (var row in report.ExcelRows) { var recipient = ReplaceContentWithValue(row, campaignVM.RecipientField); string number = recipient.Replace("+", "").Replace("-", "").Replace(" ", ""); ; Sms sms = new Sms { Content = ReplaceContentWithValue(row, campaignVM.Content), CampaignId = campaign.Id, Id = 0, StatusId = (int)MessageStatus.New, StatusDate = DateTime.Now, ToNumber = number }; smsList.Add(sms); } campaignService.SaveCampaignSmses(smsList); } return campaign.Id; } catch (Exception ex) { throw ex; } }
public ScheduleService() { campaignService = new CampaignService(); }
public ScheduleService() { campaignService = new CampaignService(); }