예제 #1
0
        public static bool UserHasPermission(string permission)
        {
            string role = UserModule.GetLoggedUserRole();

            if (UserPermissions(role).Contains(permission))
            {
                return(true);
            }
            return(false);
        }
예제 #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);
        }
예제 #3
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;
            }
        }