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()); } }
void IDataStore.Remove(Subscription sub) { if (sub != null) { foreach (Subscription s in Subscriptions.Where(s => s.Phone == sub.Phone)) { Subscriptions.Remove(s); } SaveChanges(); } }
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(); }
void IDataStore.Save(Subscription sub) { if (!Subscriptions.Any(s => s.Id == sub.Id)) { Subscriptions.Add(sub); } SaveChanges(); }
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); } } }
public void Save(Subscription sub) { lock (_lock) { if (sub.Id == 0) { sub.Id = NextId(); } _subscriptions[sub.Id] = sub; } }
public void Remove(Subscription sub) { lock (_lock) { _subscriptions.Remove(sub.Id); } }