コード例 #1
0
        // Inherited from MembershipProvider ==> Forwarded to previous provider if this provider hasn't been initialized
        public override bool DeleteUser(string username, bool deleteAllRelatedData)
        {
            if (!InitializeCalled)
            {
                return(PreviousProvider.DeleteUser(username, deleteAllRelatedData));
            }
            if (username.IsEmpty())
            {
                ExceptionHelper.CreateArgumentNullOrEmptyException("username");
            }
            using (var db = ConnectToDatabase()) {
                int userId = GetUserId(db, SafeUserTableName, SafeUserNameColumn, SafeUserIdColumn, username);
                if (userId == -1)
                {
                    return(false); // User not found
                }
                int  deleted     = db.Execute(@"DELETE FROM " + SafeUserTableName + " WHERE " + SafeUserIdColumn + " = @0", userId);
                bool returnValue = (deleted == 1);

                //if (deleteAllRelatedData) {
                // REVIEW: do we really want to delete from the user table?
                //}
                return(returnValue);
            }
        }
コード例 #2
0
        // Inherited from MembershipProvider ==> Forwarded to previous provider if this provider hasn't been initialized
        public override bool DeleteUser(string username, bool deleteAllRelatedData)
        {
            if (!InitializeCalled)
            {
                return(PreviousProvider.DeleteUser(username, deleteAllRelatedData));
            }

            MembershipAccount user;

            try
            {
                user = GetUser(username);
            }
            catch (Exception)
            {
                return(false);
            }
            user.CatchAll = null;
            bool returnValue = false;

            try
            {
                _session.Save(user);
                returnValue = true;
            }
            catch (Exception)
            {
            }

            //if (deleteAllRelatedData) {
            // REVIEW: do we really want to delete from the user table?
            //}
            return(returnValue);
        }