Пример #1
0
        ///<summary>
        ///Retrieve user from file
        ///</summary>
        ///<param name="email">string</param>
        ///<param name="email">string</param>
        ///<returns>User class object</returns>
        ///<remarks>
        ///</remarks>
        public User retreiveUser(string email, string password)
        {

            User rUser = null;

            //find user from database
            DataTableOperations source = 
                new DataTableOperations(Properties.Settings.Default.ConnectionString,
                     Properties.Settings.Default.LoginSQL, "Login");

            DataTable t = new DataTable();
            t = source.Datatable;
            foreach (DataRow item in t.Rows)
            {
                if (item["email"].ToString().Equals(email)) 
                {           
                    if (item["password"].ToString().Equals(User.HashPass(password,email)))
                    {
                        rUser = new User(email, password);
                    }
                }
                else
                {
                    Console.Write("Record not found");
                }      
                
            }

            return rUser;
        }
Пример #2
0
        ///<summary>
        ///Add user to Database
        ///</summary>
        ///<param name=""></param>
        ///<returns>Boolean value</returns>
        ///<remarks>
        ///
        ///</remarks>
        public static bool SubmitUser()
        {
            bool saved = false;
            string[] field = new string[] {"email","password"}; 
            string[] values = new string[] {user.Email, user.Password};

            DataTableOperations target = new DataTableOperations(Properties.Settings.Default.ConnectionString);
            target.InsertString("Login", field, values);
         
            return saved;
        }