コード例 #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);
 }