Example #1
0
        public CampaignVM GetCampaign(int campaignId)
        {
            CampaignService campaignService = new CampaignService();
            var campaign = campaignService.GetCampaign(campaignId);

            CampaignAdapter adapter = new CampaignAdapter();
            return adapter.GetVMFromCampaign(campaign);
        }
Example #2
0
        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;
        }
Example #3
0
 public bool RejectCampaign(int campaignId)
 {
     CampaignService campaignService = new CampaignService();
     return campaignService.UpdateCampaignStatus(campaignId, CampaignStatus.Rejected);
 }
Example #4
0
 public IEnumerable<Sms> GetCampaignSmses(int campaignId, MessageStatus status = MessageStatus.All)
 {
     CampaignService campaignService = new CampaignService();
     return campaignService.GetCampaignSmses(campaignId, status);
 }
Example #5
0
 public bool ApproveCampaign(int campaignId)
 {
     CampaignService campaignService = new CampaignService();
     return campaignService.UpdateCampaignStatus(campaignId, CampaignStatus.Approved);
 }
Example #6
0
 public bool DeleteCampaign(int campaignId)
 {
     CampaignService campaignService = new CampaignService();
     return campaignService.DeleteCampaign(campaignId);
 }
Example #7
0
 public bool StopCampaign(int campaignId)
 {
     CampaignService campaignService = new CampaignService();
     return campaignService.UpdateCampaignStatus(campaignId, CampaignStatus.Stopped);
 }
Example #8
0
        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);
        }
Example #9
0
 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;
 }
Example #10
0
 public bool ScheduleCampaign(int campaignId, DateTime scheduledDate)
 {
     CampaignService campaignService = new CampaignService();
     return campaignService.UpdateCampaignStatus(campaignId, CampaignStatus.Scheduled, scheduledDate);
 }
Example #11
0
        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;
            }
        }
Example #12
0
 public ScheduleService()
 {
     campaignService = new CampaignService();
 }
Example #13
0
 public ScheduleService()
 {
     campaignService = new CampaignService();
 }