예제 #1
0
파일: Join.cs 프로젝트: bubbafat/TellHer
        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());
            }
        }
예제 #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();
            }
        }
예제 #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();
        }
예제 #4
0
        void IDataStore.Save(Subscription sub)
        {
            if (!Subscriptions.Any(s => s.Id == sub.Id))
            {
                Subscriptions.Add(sub);
            }

            SaveChanges();
        }
예제 #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);
         }
     }
 }
예제 #6
0
        public void Save(Subscription sub)
        {
            lock (_lock)
            {
                if (sub.Id == 0)
                {
                    sub.Id = NextId();
                }

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