示例#1
0
        public async Task <IdentityResult> DeleteAsync(MyApplicationUser user)
        {
            string sql  = "DELETE FROM dbo.CustomUser WHERE Id = @Id";
            int    rows = await _connection.ExecuteAsync(sql, new { user.Id });

            if (rows > 0)
            {
                return(IdentityResult.Success);
            }
            return(IdentityResult.Failed(new IdentityError {
                Description = $"Could not delete user {user.Email}."
            }));
        }
示例#2
0
        public async Task <IdentityResult> CreateAsync(MyApplicationUser user)
        {
            string sql = "INSERT INTO dbo.CustomUser " +
                         "VALUES (@id, @Email, @EmailConfirmed, @PasswordHash, @UserName)";

            int rows = await _connection.ExecuteAsync(sql, new { user.Id, user.Email, user.EmailConfirmed, user.PasswordHash, user.UserName });

            if (rows > 0)
            {
                return(IdentityResult.Success);
            }
            return(IdentityResult.Failed(new IdentityError {
                Description = $"Could not insert user {user.Email}."
            }));
        }