public static string UnregisterPerson(string phoneNumber) { //yea, yea.. there should probably be a flag in this database like 'active' that determines if they're registered... or even a history table that stores the old info so we can delete it from here, but for now this works and I don't lose who has used the system :) //large reason for now for saving who has used it - if someone abuses it and starts costing me lots of money, I can track that down easier var phoneInDb = GetPhoneEnrollment(phoneNumber); if (phoneInDb == null) { return(SMSResponseMessages.UnknownPhoneMessage(phoneNumber)); } try { using (var db = new WebAPIDemoSMSContestContext()) { phoneInDb.Phone = "Unregistered-" + phoneInDb.Phone; phoneInDb.UpdatedDate = DateTime.Now; db.Enrollments.Attach(phoneInDb); db.Entry(phoneInDb).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(SMSResponseMessages.UnregisteredMessage(phoneNumber)); } } catch { return(SMSResponseMessages.ErrorMessage(phoneNumber)); } }
public static string ParseSmsMessage(SmsRequest request) { var actionString = request.Body.Split(' ').FirstOrDefault().Replace("\"", ""); var values = String.Join(" ", (request.Body.Split(' ')).Skip(1)); if (!IsPhoneRegistered(request.From) && actionString.ToLower() != "join" && actionString.ToLower() != "game" && actionString.ToLower() != "win") { PhoneInDb = null; return(SMSResponseMessages.UnknownPhoneMessage(request.From)); } if (IsPhoneRegistered(request.From) && actionString.ToLower() == "join") { PhoneInDb = null; return(SMSResponseMessages.AlreadyRegisteredMessage(request.From)); } ParseSMSRequestAction(request, actionString.ToLower(), values); PhoneInDb = null; return(ResponseString); }