Example #1
0
		private void detach_SMSLists(SMSList entity)
		{
			this.SendPropertyChanging();
			entity.Person = null;
		}
Example #2
0
		private void attach_SMSLists(SMSList entity)
		{
			this.SendPropertyChanging();
			entity.Person = this;
		}
Example #3
0
 private void detach_SMSLists(SMSList entity)
 {
     this.SendPropertyChanging();
     entity.SmsReceived = null;
 }
Example #4
0
 private void detach_SMSLists(SMSList entity)
 {
     this.SendPropertyChanging();
     entity.SMSGroup = null;
 }
Example #5
0
 private void attach_SMSLists(SMSList entity)
 {
     this.SendPropertyChanging();
     entity.SMSGroup = this;
 }
Example #6
0
        public static void QueueSMS(Guid iQBID, int iSendGroupID, string sTitle, string sMessage)
        {
            var q = DbUtil.Db.PeopleQuery(iQBID);

            // Create new SMS send list
            var list = new SMSList();

            list.Created = DateTime.Now;
            list.SendAt = DateTime.Now;
            list.SenderID = Util.UserPeopleId ?? 1;
            list.SendGroupID = iSendGroupID;
            list.Title = sTitle;
            list.Message = sMessage;

            DbUtil.Db.SMSLists.InsertOnSubmit(list);
            DbUtil.Db.SubmitChanges();

            // Load all people but tell why they can or can't be sent to

            foreach (var i in q)
            {
                var item = new SMSItem();

                item.ListID = list.Id;
                item.PeopleID = i.PeopleId;

                if (i.CellPhone != null && i.CellPhone.Length > 0)
                {
                    item.Number = i.CellPhone;
                }
                else
                {
                    item.Number = "";
                    item.NoNumber = true;
                }

                if (!i.ReceiveSMS)
                {
                    item.NoOptIn = true;
                }

                DbUtil.Db.SMSItems.InsertOnSubmit(item);
            }

            DbUtil.Db.SubmitChanges();

            // Check for how many people have cell numbers and want to receive texts
            var qSMS = from p in q
                where p.CellPhone != null
                where p.ReceiveSMS == true
                select p;

            var countSMS = qSMS.Count();

            /*
            if (countSMS > 0)
            {
                foreach (var i in qSMS)
                {
                    var item = new SMSItem();

                    item.ListID = list.Id;
                    item.PeopleID = i.PeopleId;
                    item.Number = i.CellPhone;

                    DbUtil.Db.SMSItems.InsertOnSubmit(item);
                }
            }
            */

            // Add counts for SMS, e-Mail and none
            list.SentSMS = countSMS;
            list.SentNone = q.Count() - countSMS;

            DbUtil.Db.SubmitChanges();

            ProcessQueue(list.Id);
        }