USP_GET_SITEPAGE_BBPAYTEMPLATE_PREVIEW_MODEL

Parameters

Parameter Parameter Type Mode Description
@SITEPAGEID int IN
@DESKTOP_DELIVERYCHANNELID uniqueidentifier IN
@MOBILE_DELIVERYCHANNELID uniqueidentifier IN
@ENVIRONMENTID uniqueidentifier IN

Definition

Copy


CREATE procedure dbo.USP_GET_SITEPAGE_BBPAYTEMPLATE_PREVIEW_MODEL
(
  @SITEPAGEID int,
  @DESKTOP_DELIVERYCHANNELID uniqueidentifier,
  @MOBILE_DELIVERYCHANNELID uniqueidentifier,
  @ENVIRONMENTID uniqueidentifier
)
as
begin
    declare @DESKTOP_TEMPLATEID uniqueidentifier,
          @MOBILE_TEMPLATEID uniqueidentifier,
              @BBPAYTEMPLATEVERSION smallint;

  -- Get the Mobile and Desktop template ids of this page and environment 

  declare @TEMPLATEIDS table(TemplateId uniqueidentifier, DeliveryChannelId uniqueidentifier);
  insert into @TEMPLATEIDS(TemplateId, DeliveryChannelId)
  select E.ID, T.DELIVERYCHANNELID 
  from dbo.CRMBBPayTemplate T
  inner join dbo.BBPayEnvironmentTemplate E on T.ID = E.TEMPLATEID and E.ENVIRONMENTID = @ENVIRONMENTID
  where T.SITEPAGEID = @SITEPAGEID;
  -- Set the desktop id and the mobile id, respectively

  select @DESKTOP_TEMPLATEID = TemplateId from @TEMPLATEIDS where DeliveryChannelId = @DESKTOP_DELIVERYCHANNELID;
  select @MOBILE_TEMPLATEID = TemplateId from @TEMPLATEIDS where DeliveryChannelId = @MOBILE_DELIVERYCHANNELID;

  -- Set the BBPay Template version based on the page id

  select @BBPAYTEMPLATEVERSION = BBPAYTEMPLATEVERSION from dbo.CMSSitePageBBPayTemplateVersion where SitePageId = @SITEPAGEID and EnvironmentId = @ENVIRONMENTID;

  -- return everything

  select @SITEPAGEID as PageId,
         @DESKTOP_TEMPLATEID as DesktopTemplateId,
         @MOBILE_TEMPLATEID as MobileTemplateId,
         @BBPAYTEMPLATEVERSION as CurrentVersion,
         @ENVIRONMENTID as EnvironmentId
  -- setting a where to check that the desktop template id is not nothing because without that we have nothing worth returning

  where @DESKTOP_TEMPLATEID is not null;

end