You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.7 KiB
62 lines
1.7 KiB
CREATE OR ALTER PROCEDURE [dbo].[Cipher_UpdateWithCollections] |
|
@Id UNIQUEIDENTIFIER, |
|
@UserId UNIQUEIDENTIFIER, |
|
@OrganizationId UNIQUEIDENTIFIER, |
|
@Type TINYINT, |
|
@Data NVARCHAR(MAX), |
|
@Favorites NVARCHAR(MAX), |
|
@Folders NVARCHAR(MAX), |
|
@Attachments NVARCHAR(MAX), |
|
@CreationDate DATETIME2(7), |
|
@RevisionDate DATETIME2(7), |
|
@DeletedDate DATETIME2(7), |
|
@Reprompt TINYINT, |
|
@Key VARCHAR(MAX) = NULL, |
|
@CollectionIds AS [dbo].[GuidIdArray] READONLY, |
|
@ArchivedDate DATETIME2(7) = NULL |
|
AS |
|
BEGIN |
|
SET NOCOUNT ON |
|
|
|
BEGIN TRANSACTION Cipher_UpdateWithCollections |
|
|
|
DECLARE @UpdateCollectionsSuccess INT |
|
EXEC @UpdateCollectionsSuccess = [dbo].[Cipher_UpdateCollections] @Id, @UserId, @OrganizationId, @CollectionIds |
|
|
|
IF @UpdateCollectionsSuccess < 0 |
|
BEGIN |
|
COMMIT TRANSACTION Cipher_UpdateWithCollections |
|
SELECT -1 -- -1 = Failure |
|
RETURN |
|
END |
|
|
|
UPDATE |
|
[dbo].[Cipher] |
|
SET |
|
[UserId] = NULL, |
|
[OrganizationId] = @OrganizationId, |
|
[Data] = @Data, |
|
[Attachments] = @Attachments, |
|
[RevisionDate] = @RevisionDate, |
|
[DeletedDate] = @DeletedDate, |
|
[Key] = @Key, |
|
[ArchivedDate] = @ArchivedDate, |
|
[Folders] = @Folders, |
|
[Favorites] = @Favorites, |
|
[Reprompt] = @Reprompt |
|
-- No need to update CreationDate or Type since that data will not change |
|
WHERE |
|
[Id] = @Id |
|
|
|
COMMIT TRANSACTION Cipher_UpdateWithCollections |
|
|
|
IF @Attachments IS NOT NULL |
|
BEGIN |
|
EXEC [dbo].[Organization_UpdateStorage] @OrganizationId |
|
EXEC [dbo].[User_UpdateStorage] @UserId |
|
END |
|
|
|
EXEC [dbo].[User_BumpAccountRevisionDateByCipherId] @Id, @OrganizationId |
|
|
|
SELECT 0 -- 0 = Success |
|
END
|
|
|