/// <summary> /// This function will register a new user for use with the system. User data is /// stored in the database. Parameters do not require sanitizing. /// </summary> /// <param name="usern">This is the username for the new account</param> /// <param name="pass">This is the hashed password for the new account</param> /// <returns>Returns true if account insertion is successful</returns> public bool registerUser(string usern, string pass) { bool success = false; using (var db = new stock_advisorDataContext(Program.ConnectionString)) { //create user_info object w/params var newUser = new USER_INFO() { Username = usern, Password = pass }; db.USER_INFOs.InsertOnSubmit(newUser); try { db.SubmitChanges(); //execute insert //verify that was successfully inserted var added = db.USER_INFOs.SingleOrDefault(a => a.Username == usern && a.Password == pass); if (added != null) { success = true; } } catch (Exception e) { Console.WriteLine("Exception caught during account creation/insert:\n"); Console.WriteLine(e.Message); } } return(success); }
partial void UpdateUSER_INFO(USER_INFO instance);
partial void DeleteUSER_INFO(USER_INFO instance);
partial void InsertUSER_INFO(USER_INFO instance);