Beispiel #1
0
        /// <summary>
        /// Deletes all claims from a user given a userId.
        /// </summary>
        /// <param name="userId">The user's id.</param>
        /// <returns></returns>
        public int Delete(Guid userId)
        {
            String commandText = "DELETE FROM \"AspNetUserClaims\" WHERE \"UserId\" = @userId";
            Dictionary <String, Object> parameters = new Dictionary <String, Object>();

            parameters.Add("userId", userId);

            return(_database.Execute(commandText, parameters));
        }
Beispiel #2
0
        /// <summary>
        /// Deletes a role record from the AspNetRoles table.
        /// </summary>
        /// <param name="roleId">The role Id</param>
        /// <returns></returns>
        public int Delete(String roleId)
        {
            String commandText = "DELETE FROM \"AspNetRoles\" WHERE \"Id\" = @id";
            Dictionary <String, Object> parameters = new Dictionary <String, Object>();

            parameters.Add("@id", roleId);

            return(_database.Execute(commandText, parameters));
        }
Beispiel #3
0
        /// <summary>
        /// Deletes role from a user in the AspNetUserRoles table.
        /// </summary>
        /// <param name="userId">The user's id.</param>
        /// <returns></returns>
        public int Delete(Guid userId, String role)
        {
            String commandText = "DELETE FROM \"AspNetUserRoles\" WHERE \"UserId\" = @userId AND \"RoleId\" = @Role;";
            Dictionary <String, Object> parameters = new Dictionary <String, Object>();

            parameters.Add("UserId", userId);
            parameters.Add("Role", role);

            return(_database.Execute(commandText, parameters));
        }
Beispiel #4
0
        /// <summary>
        /// Deletes a login record from a user in the UserLogins table.
        /// </summary>
        /// <param name="user">User to have login deleted.</param>
        /// <param name="login">Login to be deleted from user.</param>
        /// <returns></returns>
        public int Delete(IdentityUser user, UserLoginInfo login)
        {
            String commandText = "DELETE FROM \"AspNetUserLogins\" WHERE \"UserId\" = @userId AND \"LoginProvider\" = @loginProvider AND \"ProviderKey\" = @providerKey";
            Dictionary <String, Object> parameters = new Dictionary <String, Object>();

            parameters.Add("UserId", user.Id);
            parameters.Add("loginProvider", login.LoginProvider);
            parameters.Add("providerKey", login.ProviderKey);

            return(_database.Execute(commandText, parameters));
        }
Beispiel #5
0
        /// <summary>
        /// Sets the user's password hash.
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="passwordHash"></param>
        /// <returns></returns>
        public Int32 SetPasswordHash(Guid userId, String passwordHash)
        {
            if (String.IsNullOrWhiteSpace(passwordHash))
            {
                throw new ArgumentNullException(nameof(passwordHash));
            }

            const string commandText = "UPDATE \"AspNetUsers\" SET \"PasswordHash\" = @pwdHash WHERE \"Id\" = @id";
            var          parameters  = new Dictionary <String, Object>();

            parameters.Add("@pwdHash", passwordHash);
            parameters.Add("@id", userId);

            return(_database.Execute(commandText, parameters));
        }