예제 #1
0
        public static string CreatePhoneUser(string phone, int pin)
        {
            //TODO -- Error Check!
            string errorMessage = "";

            LData.DBDataContext db = new DBDataContext(Constants.AppConnectionString);

            //Verify phone number doesn't exist
            if (!DoesPhoneNumberExist(phone))
            {
                LData.PhoneUser user = new PhoneUser();
                user.ID = Guid.NewGuid();
                user.PhoneNumber = phone;
                user.PIN = pin;
                user.DateCreated = DateTime.Now;
                user.DateLastAccessed = Constants.NullDate;
                user.DateActivated = DateTime.Now;

                db.PhoneUsers.InsertOnSubmit(user);
                db.SubmitChanges();
            }
            else
            {
                errorMessage = "I'm sorry, you already have an account!";
            }

            return errorMessage;
        }
예제 #2
0
        public static string CreatePhoneUser(string phone, int pin)
        {
            //TODO -- Error Check!
            string errorMessage = "";

            LData.DBDataContext db = new DBDataContext(Constants.AppConnectionString);

            //Verify phone number doesn't exist
            if (!DoesPhoneNumberExist(phone))
            {
                LData.PhoneUser user = new PhoneUser();
                user.ID               = Guid.NewGuid();
                user.PhoneNumber      = phone;
                user.PIN              = pin;
                user.DateCreated      = DateTime.Now;
                user.DateLastAccessed = Constants.NullDate;
                user.DateActivated    = DateTime.Now;

                db.PhoneUsers.InsertOnSubmit(user);
                db.SubmitChanges();
            }
            else
            {
                errorMessage = "I'm sorry, you already have an account!";
            }

            return(errorMessage);
        }
예제 #3
0
        public static void UpdateLastAccessedDate(string phoneNumber)
        {
            LData.DBDataContext db = new DBDataContext(Constants.AppConnectionString);

            //Get the record from db
            LData.PhoneUser user = db.PhoneUsers.FirstOrDefault(p => p.PhoneNumber == phoneNumber);

            if (user != null)
            {
                user.DateLastAccessed = DateTime.Now;
                db.SubmitChanges();
            }
        }
예제 #4
0
        public static void SaveUserPrefs(string phoneNumber, int zipCode, string keyWords)
        {
            LData.DBDataContext db = new DBDataContext(Constants.AppConnectionString);

            //Get the record from db
            LData.PhoneUser user = db.PhoneUsers.FirstOrDefault(p => p.PhoneNumber == phoneNumber);

            if (user != null)
            {
                user.ZipCode = zipCode;
                user.KeyWords = keyWords;

                db.SubmitChanges(); //save back to db
            }
        }
예제 #5
0
        public static void SaveUserPrefs(string phoneNumber, int zipCode, string keyWords)
        {
            LData.DBDataContext db = new DBDataContext(Constants.AppConnectionString);

            //Get the record from db
            LData.PhoneUser user = db.PhoneUsers.FirstOrDefault(p => p.PhoneNumber == phoneNumber);

            if (user != null)
            {
                user.ZipCode  = zipCode;
                user.KeyWords = keyWords;

                db.SubmitChanges(); //save back to db
            }
        }
예제 #6
0
        public static void GetUserPrefs(string phoneNumber, out int zipCode, out string keyWords)
        {
            zipCode = 0;
            keyWords = "";

            LData.DBDataContext db = new DBDataContext(Constants.AppConnectionString);

            //Get the record from db
            LData.PhoneUser user = db.PhoneUsers.FirstOrDefault(p => p.PhoneNumber == phoneNumber);

            if (user != null)
            {
                zipCode = user.ZipCode == null ? 0 : (int)user.ZipCode;
                keyWords = user.KeyWords;
            }
        }
예제 #7
0
        public static void GetUserPrefs(string phoneNumber, out int zipCode, out string keyWords)
        {
            zipCode  = 0;
            keyWords = "";

            LData.DBDataContext db = new DBDataContext(Constants.AppConnectionString);

            //Get the record from db
            LData.PhoneUser user = db.PhoneUsers.FirstOrDefault(p => p.PhoneNumber == phoneNumber);

            if (user != null)
            {
                zipCode  = user.ZipCode == null ? 0 : (int)user.ZipCode;
                keyWords = user.KeyWords;
            }
        }
예제 #8
0
        public static void UpdateLastAccessedDate(string phoneNumber)
        {
            LData.DBDataContext db = new DBDataContext(Constants.AppConnectionString);

             //Get the record from db
            LData.PhoneUser user = db.PhoneUsers.FirstOrDefault(p => p.PhoneNumber == phoneNumber);

            if (user != null)
            {
                user.DateLastAccessed = DateTime.Now;
                db.SubmitChanges();
            }
        }
예제 #9
0
 public static bool DoesUserHaveCorrectCredentials(string phone, int pin)
 {
     LData.DBDataContext db = new DBDataContext(Constants.AppConnectionString);
      return db.PhoneUsers.FirstOrDefault(p => p.PhoneNumber == phone && p.PIN == pin) == null ? false : true;
 }
예제 #10
0
 public static bool DoesPinExist(int pin)
 {
     LData.DBDataContext db = new DBDataContext(Constants.AppConnectionString);
     return db.PhoneUsers.FirstOrDefault(p => p.PIN == pin) == null ? false : true;
 }
예제 #11
0
 public static bool DoesPhoneNumberExist(string phoneNumber)
 {
     LData.DBDataContext db = new DBDataContext(Constants.AppConnectionString);
     return db.PhoneUsers.FirstOrDefault(p => p.PhoneNumber == phoneNumber) == null ? false : true;
 }
예제 #12
0
 public static bool DoesPinExist(int pin)
 {
     LData.DBDataContext db = new DBDataContext(Constants.AppConnectionString);
     return(db.PhoneUsers.FirstOrDefault(p => p.PIN == pin) == null ? false : true);
 }
예제 #13
0
 public static bool DoesUserHaveCorrectCredentials(string phone, int pin)
 {
     LData.DBDataContext db = new DBDataContext(Constants.AppConnectionString);
     return(db.PhoneUsers.FirstOrDefault(p => p.PhoneNumber == phone && p.PIN == pin) == null ? false : true);
 }
예제 #14
0
 public static bool DoesPhoneNumberExist(string phoneNumber)
 {
     LData.DBDataContext db = new DBDataContext(Constants.AppConnectionString);
     return(db.PhoneUsers.FirstOrDefault(p => p.PhoneNumber == phoneNumber) == null ? false : true);
 }