Exemplo n.º 1
0
        public static bool InsertUser(UserCS sr)
        {
            bool          blnSuccess = false;
            SqlConnection cn         = new SqlConnection(
                ConfigurationManager.ConnectionStrings["SE265_BoozeTekConnectionString"].ConnectionString);
            SqlCommand cmd = new SqlCommand("user_insert", cn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add(
                "@user_email", SqlDbType.VarChar).Value = sr.User_Email;
            cmd.Parameters.Add(
                "@user_pwd", SqlDbType.VarChar).Value = sr.User_Pwd;
            cmd.Parameters.Add(
                "@user_salt", SqlDbType.VarChar).Value = sr.User_Salt;
            cmd.Parameters.Add(
                "@admin_rights", SqlDbType.Bit).Value = sr.Admin_Rights;

            try
            {
                cn.Open();
                cmd.ExecuteNonQuery();
                blnSuccess = true;
            }
            catch (Exception exc)
            {
                exc.ToString();
                blnSuccess = false;
            }
            finally
            {
                cn.Close();
            }
            return(blnSuccess);
        }
Exemplo n.º 2
0
        public static bool DeleteUser(UserCS sr)
        {
            bool          blnSuccess = false;
            SqlConnection cn         = new SqlConnection(
                ConfigurationManager.ConnectionStrings["SE265_BoozeTekConnectionString"].ConnectionString);
            SqlCommand cmd = new SqlCommand("User_Delete", cn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add(
                "@user_id", SqlDbType.Int).Value = sr.User_ID;

            try
            {
                cn.Open();
                cmd.ExecuteNonQuery();
                blnSuccess = true;
            }
            catch (Exception exc)
            {
                exc.ToString();
                blnSuccess = false;
            }
            finally
            {
                cn.Close();
            }
            return(blnSuccess);
        }
Exemplo n.º 3
0
        public static AppUser Login(string email, string password)
        {
            AppUser au           = new AppUser(email);
            string  testPassword = UserCS.CreatePasswordHash(au.Salt, password);

            if (au.HashedPassword == testPassword)
            {
                au.ValidLogin = true;
            }
            else
            {
                au.ValidLogin = false;
            }

            return(au);
        }