USP_MICROSITEMEMBERSHIPLEVEL_OFFLINE

Executes the "Microsite Membership Level Offline" record operation.

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN Input parameter indicating the ID of the record being deleted.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the delete.

Definition

Copy


                    CREATE procedure dbo.USP_MICROSITEMEMBERSHIPLEVEL_OFFLINE
                    (
                        @ID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier
                    )
                    as begin
                        declare @MEMBERSHIPPROGRAMID uniqueidentifier = null
                        select @MEMBERSHIPPROGRAMID = [MEMBERSHIPLEVEL].[MEMBERSHIPPROGRAMID]
                        from dbo.[MEMBERSHIPLEVEL]
                        where [ID] = @ID

                        begin try
                            exec dbo.USP_MICROSITEMEMBERSHIPLEVEL_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID

                            --If there are no more membership levels online, make the program offline

                            if not exists(
                                select 1
                                from dbo.[MEMBERSHIPLEVEL]
                                inner join dbo.[MICROSITEMEMBERSHIPLEVEL]
                                    on [MEMBERSHIPLEVEL].[ID] = [MICROSITEMEMBERSHIPLEVEL].[ID]
                                where [MEMBERSHIPLEVEL].[MEMBERSHIPPROGRAMID] = @MEMBERSHIPPROGRAMID
                            )
                            begin
                                exec dbo.USP_MEMBERSHIPPROGRAM_BASICCMS_DELETE @MEMBERSHIPPROGRAMID, @CHANGEAGENTID
                            end
                        end try
                        begin catch
                            exec dbo.USP_RAISE_ERROR
                            return 1
                        end catch

                        return 0;
                    end