Ejemplo n.º 1
0
        public CampaignVM GetCampaign(int campaignId)
        {
            CampaignService campaignService = new CampaignService();
            var campaign = campaignService.GetCampaign(campaignId);

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