コード例 #1
0
        /// <summary>
        /// Inserts a new role record for a user in the UserRoles table.
        /// </summary>
        /// <param name="user">The User.</param>
        /// <param name="roleId">The Role's id.</param>
        /// <returns></returns>
        public int Insert(IdentityUser user, string roleId)
        {
            string commandText = "INSERT INTO "+fullTableName+" ("+fieldUserID.Quoted()+", "+fieldRoleID.Quoted()+") VALUES (@userId, @roleId)";
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("userId", user.Id);
            parameters.Add("roleId", roleId);

            return _database.Execute(commandText, parameters);
        }
コード例 #2
0
        /// <summary>
        /// Inserts a new role record for a user in the UserRoles table.
        /// </summary>
        /// <param name="user">The User.</param>
        /// <param name="roleId">The Role's id.</param>
        /// <returns></returns>
        public int Insert(IdentityUser user, string roleId)
        {
            string commandText = "INSERT INTO \"AspNetUserRoles\" (\"UserId\", \"RoleId\") VALUES (@userId, @roleId)";
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("userId", user.Id);
            parameters.Add("roleId", roleId);

            return _database.Execute(commandText, parameters);
        }
コード例 #3
0
        /// <summary>
        /// Deletes a claim record from a user.
        /// </summary>
        /// <param name="user">The user to have a claim deleted.</param>
        /// <param name="claim">A claim to be deleted from user.</param>
        /// <returns></returns>
        public int Delete(IdentityUser user, Claim claim)
        {
            string commandText = "DELETE FROM \"AspNetUserClaims\" WHERE \"UserId\" = @userId AND @ClaimValue = @value AND ClaimType = @type";
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("userId", user.Id);
            parameters.Add("value", claim.Value);
            parameters.Add("type", claim.Type);

            return _database.Execute(commandText, parameters);
        }
コード例 #4
0
        /// <summary>
        /// Inserts a new login record in the AspNetUserLogins table.
        /// </summary>
        /// <param name="user">User to have new login added.</param>
        /// <param name="login">Login to be added.</param>
        /// <returns></returns>
        public int Insert(IdentityUser user, UserLoginInfo login)
        {
            string commandText = "INSERT INTO \"AspNetUserLogins\" (\"LoginProvider\", \"ProviderKey\", \"UserId\") VALUES (@loginProvider, @providerKey, @userId)";
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("loginProvider", login.LoginProvider);
            parameters.Add("providerKey", login.ProviderKey);
            parameters.Add("userId", user.Id);

            return _database.Execute(commandText, parameters);
        }
コード例 #5
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);
        }
コード例 #6
0
        /// <summary>
        /// Inserts a new login record in the AspNetUserLogins table.
        /// </summary>
        /// <param name="user">User to have new login added.</param>
        /// <param name="login">Login to be added.</param>
        /// <returns></returns>
        public int Insert(IdentityUser user, UserLoginInfo login)
        {
            string commandText = "INSERT INTO "+fullTableName+"  ("+fieldLoginProvider.Quoted()+", "+fieldProviderKey.Quoted()+", "+fielduserID.Quoted()+") "+
                                                                "VALUES (@loginProvider, @providerKey, @userId)";
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("loginProvider", login.LoginProvider);
            parameters.Add("providerKey", login.ProviderKey);
            parameters.Add("userId", user.Id);

            return _database.Execute(commandText, parameters);
        }
コード例 #7
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 "+fullTableName+" WHERE "+fielduserID.Quoted()+" = @userId AND "+fieldLoginProvider.Quoted()+" = @loginProvider "+
                " AND "+fieldProviderKey.Quoted() + " = @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);
        }
コード例 #8
0
        /// <summary>
        /// Deletes a claim record from a user.
        /// </summary>
        /// <param name="user">The user to have a claim deleted.</param>
        /// <param name="claim">A claim to be deleted from user.</param>
        /// <returns></returns>
        public int Delete(IdentityUser user, Claim claim)
        {
            string commandText = "DELETE FROM "+fullTableName+" WHERE "+fieldUserID.Quoted()+" = @userId "+
                " AND "+fieldClaimValue.Quoted()+" = @value AND "+fieldClaimType.Quoted()+" = @type";
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("userId", user.Id);
            parameters.Add("value", claim.Value);
            parameters.Add("type", claim.Type);

            return _database.Execute(commandText, parameters);
        }