Example #1
0
        protected override void PerformUnknownUser(Domain.IncomingSmsMessage message)
        {
            IDataStore store = DataStore.GetInstance();
            IConfiguration config = Configuration.GetInstance();

            if (store.Subscriptions.Count() < config.BetaLimit)
            {
                Subscription s = new Subscription
                {
                    Phone = message.From,
                    Next = DateTime.UtcNow,
                };

                store.Save(s);

                Say(message.From, SmsResponseStrings.Join_Created());
            }
            else
            {
                Say(message.From, SmsResponseStrings.Join_SorryBetaFull());
                Say(config.AdminNumber, SmsResponseStrings.Join_AdminBetaReject());
            }
        }
Example #2
0
        void IDataStore.Remove(Subscription sub)
        {
            if (sub != null)
            {
                foreach (Subscription s in Subscriptions.Where(s => s.Phone == sub.Phone))
                {
                    Subscriptions.Remove(s);
                }

                SaveChanges();
            }
        }
Example #3
0
        void IDataStore.ScheduleMessage(OutgoingSmsMessage msg, Subscription sub)
        {
            OutgoingMessages.Add(msg);
            Subscription toUpdate = Subscriptions.Where(s => s.Id == sub.Id).FirstOrDefault();
            if (toUpdate != null)
            {
                toUpdate.Next = DateTime.Today.AddDays(1).AddHours(4).ToUniversalTime();
            }

            SaveChanges();
        }
Example #4
0
        void IDataStore.Save(Subscription sub)
        {
            if (!Subscriptions.Any(s => s.Id == sub.Id))
            {
                Subscriptions.Add(sub);
            }

            SaveChanges();
        }
Example #5
0
 public void ScheduleMessage(OutgoingSmsMessage msg, Subscription sub)
 {
     lock (_lock)
     {
         Save(msg);
         Subscription toUpdate = Subscriptions.Where(s => s.Id == sub.Id).FirstOrDefault();
         if (toUpdate != null)
         {
             toUpdate.Next = DateTime.Today.AddDays(1).ToUniversalTime().AddHours(2);
         }
     }
 }
Example #6
0
        public void Save(Subscription sub)
        {
            lock (_lock)
            {
                if (sub.Id == 0)
                {
                    sub.Id = NextId();
                }

                _subscriptions[sub.Id] = sub;
            }
        }
Example #7
0
 public void Remove(Subscription sub)
 {
     lock (_lock)
     {
         _subscriptions.Remove(sub.Id);
     }
 }