Esempio n. 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;
        }
Esempio n. 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);
        }
Esempio n. 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();
            }
        }
Esempio n. 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
            }
        }
Esempio n. 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
            }
        }
Esempio n. 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;
            }
        }
Esempio n. 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;
            }
        }
Esempio n. 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();
            }
        }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 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);
 }