/// <summary> /// Checks the database for phone enrollment with SMS Bot /// </summary> /// <param name="phoneNumber"></param> /// <returns></returns> public static WebAPIDemoSMS GetPhoneEnrollment(string phoneNumber) { if (PhoneInDb != null) { return(PhoneInDb); } var phoneInDb = SMSDataHelper.GetPhoneEnrollment(phoneNumber); PhoneInDb = phoneInDb; return(phoneInDb); }
private static string RegisterPhoneForContest(string phoneNumber, string name, string email = "") { var contest = GetContestWithPeople(1); var demoSMS = contest.PeopleEnrolled.FirstOrDefault(e => e.Phone == phoneNumber); if (demoSMS == null) { demoSMS = SMSDataHelper.GetPhoneEnrollment(phoneNumber); if (demoSMS == null) { demoSMS = SMSDataHelper.RegisterPhone(phoneNumber, name, email); } if (demoSMS == null) { return("There was an error enrolling you in the contest. Your phone/name could not be added."); } try { using (var db = new WebAPIDemoSMSContestContext()) { db.Enrollments.Attach(demoSMS); db.SaveChanges(); db.Contests.Attach(contest); contest.PeopleEnrolled.Add(demoSMS); db.SaveChanges(); } } catch (Exception ex) { return("There was an error enrolling you in the contest: " + (ex.Message.Length > 80 ? ex.Message.Substring(0, 80) : ex.Message) + "..."); } return("You're now signed up to play! When you see the text that the contest has begun, reply first with the contest word given for your chance to win!"); } return("Looks like you're already signed up for the contest! Once the key word has been sent out, be first to respond to win!"); }
/// <summary> /// Does an update to unregister a phone by changing the phone number field (keeping the record for history) /// </summary> /// <param name="phoneNumber"></param> /// <returns></returns> private static string UnregisterPerson(string phoneNumber) { return(SMSDataHelper.UnregisterPerson(phoneNumber)); }
/// <summary> /// Registers a person's phone information through entity /// </summary> /// <param name="phoneNumber"></param> /// <param name="name"></param> /// <param name="email"></param> /// <returns></returns> private static bool RegisterPhone(string phoneNumber, string name, string email = "") { return(SMSDataHelper.RegisterPhone(phoneNumber, name, email) != null); }
/// <summary> /// Does a sql update through entity of the email address /// </summary> /// <param name="phoneNumber"></param> /// <param name="email"></param> /// <returns></returns> private static bool UpdateEmail(string phoneNumber, string email) { return(SMSDataHelper.UpdateEmail(phoneNumber, email)); }