USP_INVITATION_GETANDVALIDATEPACKAGESITE

Returns the site for the invitation's packages and validates the site is valid for the event.

Parameters

Parameter Parameter Type Mode Description
@EVENTID uniqueidentifier IN
@MAILPACKAGEID uniqueidentifier IN
@EMAILPACKAGEID uniqueidentifier IN
@PACKAGESITEID uniqueidentifier INOUT

Definition

Copy


            CREATE procedure dbo.USP_INVITATION_GETANDVALIDATEPACKAGESITE
            (
                @EVENTID uniqueidentifier,
                @MAILPACKAGEID uniqueidentifier,
                @EMAILPACKAGEID uniqueidentifier,
                @PACKAGESITEID uniqueidentifier output
            )
            as
            begin
                declare @MAILPACKAGESITEID uniqueidentifier;
                select @MAILPACKAGESITEID = SITEID
                from dbo.MKTPACKAGE
                where ID = @MAILPACKAGEID;

                if @MAILPACKAGESITEID is not null 
                 and not exists (select 1 from dbo.EVENTSITE where EVENTID = @EVENTID and SITEID = @MAILPACKAGESITEID)
                    raiserror('ERR_MAILPACKAGE_SITEMUSTMATCHEVENTSITE', 13, 1);

                declare @EMAILPACKAGESITEID uniqueidentifier;
                select @EMAILPACKAGESITEID = SITEID
                from dbo.MKTPACKAGE
                where ID = @EMAILPACKAGEID;

                if @EMAILPACKAGESITEID is not null 
                 and not exists (select 1 from dbo.EVENTSITE where EVENTID = @EVENTID and SITEID = @EMAILPACKAGESITEID)
                    raiserror('ERR_EMAILPACKAGE_SITEMUSTMATCHEVENTSITE', 13, 1);

                -- No need to perform this check if one of the packages isn't set

                if @MAILPACKAGEID is not null and @EMAILPACKAGEID is not null
                begin
                    if coalesce(@MAILPACKAGESITEID, '00000000-0000-0000-0000-000000000000') <> coalesce(@EMAILPACKAGESITEID, '00000000-0000-0000-0000-000000000000')
                        raiserror('ERR_MAILPACKAGE_SITEMUSTMATCHEMAILPACKAGESITE', 13, 1);
                end

                set @PACKAGESITEID = coalesce(@MAILPACKAGESITEID, @EMAILPACKAGESITEID);
            end