1-
2- BEGIN TRY
1+ BEGIN TRY
32 BEGIN TRANSACTION ;
43
5- DECLARE @NewCatalogueId INT = 0 ; -- this is the NodePathId in the resource reference table
6- DECLARE @ResourceOwnerId INT = 0 ; -- this is CreateUserId of the resources to be moved.
4+ DECLARE @CatalogueId INT = 0 ; -- this is catalog ID in the admin page
5+ DECLARE @ResourceOwnerId INT = 0 ; -- this is CreateUserId of the resources to be moved.
6+ DECLARE @NodePathId INT ;
77 DECLARE @NewNodeId INT ;
88 DECLARE @NextDisplayOrder INT ;
99
10+ Select @NodePathId = np .Id from hierarchy .CatalogueNodeVersion cnv
11+ inner join hierarchy .NodeVersion nv ON cnv .NodeVersionId = nv .Id
12+ inner join hierarchy .Node n ON nv .NodeId = n .Id
13+ inner join hierarchy .NodePath np ON n .Id = np .NodeId
14+ Where cnv .Id = @CatalogueId and cnv .Deleted = 0 and nv .Deleted = 0 and n .Deleted = 0 and np .Deleted = 0 ;
15+
1016 -- Get the NodeId for the new catalogue
11- SELECT @NewNodeId = NodeId FROM [hierarchy].[NodePath] WHERE Id = @NewCatalogueId AND Deleted = 0 ;
17+ SELECT @NewNodeId = NodeId FROM [hierarchy].[NodePath] WHERE Id = @NodePathId AND Deleted = 0 ;
1218
1319 -- Get the current max DisplayOrder for that Node
1420 SELECT @NextDisplayOrder = ISNULL (MAX (DisplayOrder), 0 ) FROM [hierarchy].[NodeResource] WHERE NodeId = @NewNodeId AND Deleted = 0 ;
@@ -23,7 +29,7 @@ BEGIN TRY
2329
2430 -- Update ResourceReference to point to new catalogue
2531 UPDATE rr
26- SET rr .NodePathId = @NewCatalogueId
32+ SET rr .NodePathId = @NodePathId
2733 FROM [resources].[ResourceReference] rr
2834 INNER JOIN @UpdatedResources ur
2935 ON rr .ResourceId = ur .ResourceId
0 commit comments