﻿

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[fis_admin_delUserGroup]
	@authaccount varchar(5)
	,@usergroup_id varchar(5)
AS
BEGIN
	SET NOCOUNT ON;
	DECLARE @utcnow datetime = GETUTCDATE();

    IF EXISTS (SELECT * FROM [dbo].[fis_usergroups] WHERE [usergroup_id] = @usergroup_id and [DateDeleted] is null)
		BEGIN

			UPDATE [dbo].[fis_usergroups]
				SET [UserDeleted] = @authaccount
				   ,[DateDeleted] = @utcnow
			 WHERE
				  [usergroup_id] = @usergroup_id;

		END

	SELECT CAST((CASE WHEN NOT EXISTS (SELECT * FROM [dbo].[fis_usergroups] WHERE [usergroup_id] = @usergroup_id and [DateDeleted] is null) THEN 1 ELSE 0 END) as bit);

END