USP_FAFEVENTWEBSITE_UPDATECONFIG

Executes the "FAF event website required configuration" record operation.

Parameters

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

Definition

Copy


create procedure dbo.USP_FAFEVENTWEBSITE_UPDATECONFIG
(
    @ID uniqueidentifier,
    @CHANGEAGENTID uniqueidentifier
)
as begin try

  declare @NEWUSERTEMPLATEID int = null,
            @FORGOTTENPWDTEMPLATEID int = null

  declare @EventContactEmail UDT_EMAILADDRESS,
          @EventContactName nvarchar(200);

  if @CHANGEAGENTID is null  
        exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output

    declare @CURRENTDATE datetime
    set @CURRENTDATE = getdate()

  select 
        @NEWUSERTEMPLATEID = SIP.NewUserTemplateID,
        @FORGOTTENPWDTEMPLATEID = SIP.ForgottenPWDTemplateID
      from SignInProperties SIP
      join PageContent PC on PC.SiteContentID = SIP.ContentID 
      join CMSSITESETTING CSS on CSS.ENUMID = 3 and CAST(CSS.VALUE as integer) = PC.SitePagesID 
      where CSS.ClientSitesID in (select CLIENTSITESID from dbo.EVENTEXTENSION where EVENTID = @ID)

  select 
        @EventContactName= CONSTITUENT.NAME, 
        @EventContactEmail = EMAILADDRESS.EMAILADDRESS 
      from dbo.EVENT 
      join dbo.CONSTITUENT on EVENT.EVENTLOCATIONCONTACTID = CONSTITUENT.ID
      left join dbo.EMAILADDRESS on CONSTITUENT.ID = EMAILADDRESS.CONSTITUENTID
      where EVENT.ID = @ID

  update dbo.EmailTemplate set
              FromAddress = @EventContactEmail,
              FromDisplayName = @EventContactName
          where ID in (@NEWUSERTEMPLATEID,@FORGOTTENPWDTEMPLATEID);   

  exec dbo.USP_FAF_MARKETING_ADD_PRIVACY_EMAIL_PREFRENCE @EVENTID=@ID;

end try
begin catch
    exec dbo.USP_RAISE_ERROR
        return 1
end catch

return 0;