Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<Folder Include="Functions\Resources" />
<Folder Include="Triggers" />
<Folder Include="Triggers\external" />
<Folder Include="Stored Procedures\External" />
</ItemGroup>
<ItemGroup>
<None Include="Scripts\learningHub_Data.sql" />
Expand Down Expand Up @@ -537,6 +538,7 @@
<None Include="Scripts\Post-Deploy\Scripts\AddDigitalLearningSolutionsExternalSystem.sql" />
<Build Include="Stored Procedures\Activity\GetAssessmentActivityCompletionPercentage.sql" />
<Build Include="Tables\Hub\PasswordResetRequests.sql" />
<Build Include="Stored Procedures\External\ExternalSystemUserCreate.sql" />
</ItemGroup>
<ItemGroup>
<None Include="Scripts\Pre-Deploy\Scripts\Card5766_AuthorTableChanges.PreDeployment.sql" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
-------------------------------------------------------------------------------
-- Author Swapnamol Abraham
-- Created 07-04-2025
-- Purpose Creates a External System user
--
-- Modification History
--
-- 07-04-2025 SA Initial Revision
-------------------------------------------------------------------------------
CREATE PROCEDURE [external].[ExternalSystemUserCreate]
(
@userId int,
@externalSystemId int,
@amendUserId INT,
@UserTimezoneOffset int = NULL
)

AS

BEGIN
BEGIN TRY
BEGIN TRAN
DECLARE @AmendDate datetimeoffset(7) = ISNULL(TODATETIMEOFFSET(DATEADD(mi, @UserTimezoneOffset, GETUTCDATE()), @UserTimezoneOffset), SYSDATETIMEOFFSET())
-- Insert into ExternalSystemUser table
INSERT INTO [external].[ExternalSystemUser]
(UserId, ExternalSystemId, Deleted, CreateUserId, CreateDate, AmendUserId, AmendDate)
SELECT @userId, @externalSystemId, 0, @amendUserId, @amendDate, @amendUserId, @amendDate

COMMIT
END TRY
BEGIN CATCH
DECLARE @ErrorMessage NVARCHAR(4000);
DECLARE @ErrorSeverity INT;
DECLARE @ErrorState INT;

SELECT
@ErrorMessage = ERROR_MESSAGE(),
@ErrorSeverity = ERROR_SEVERITY(),
@ErrorState = ERROR_STATE();

IF @@TRANCOUNT > 0
ROLLBACK TRAN;

RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState);

END CATCH
END
GO
Loading