USP_DATAFORMTEMPLATE_EDIT_FAFEVENTWEBSITE

The save procedure used by the edit dataform template "FAFEventWebsite Edit Data Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter indicating the ID of the record being edited.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@NEWUSERTEMPLATEID int IN New user email template ID
@FORGOTTENPWDTEMPLATEID int IN Forgotten password email template ID
@ACCOUNTNUMBER nvarchar(200) IN
@PROJECTCODE nvarchar(200) IN
@DESIGNATIONID uniqueidentifier IN

Definition

Copy


create procedure dbo.USP_DATAFORMTEMPLATE_EDIT_FAFEVENTWEBSITE (
    @ID uniqueidentifier,
    @CHANGEAGENTID uniqueidentifier = null,
  @NEWUSERTEMPLATEID int,
    @FORGOTTENPWDTEMPLATEID int,
  @ACCOUNTNUMBER nvarchar(200),
  @PROJECTCODE nvarchar(200),
  @DESIGNATIONID uniqueidentifier
)
as


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

    set nocount on;

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

    declare @CURRENTDATE datetime
    set @CURRENTDATE = getdate()

    begin try

    if (@NEWUSERTEMPLATEID = 0 Or @FORGOTTENPWDTEMPLATEID = 0)
      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)

    if (@DESIGNATIONID is null or @DESIGNATIONID = '00000000-0000-0000-0000-000000000000')
    begin
      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

          -- handle updating the data

          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

    if @DESIGNATIONID <> '00000000-0000-0000-0000-000000000000' and @ACCOUNTNUMBER <> '' and @PROJECTCODE <> ''
    begin

      exec dbo.USP_DATAFORMTEMPLATE_EDIT_EVENTGLMAPPING @ID=@ID, @CHANGEAGENTID=@CHANGEAGENTID, @ACCOUNTNUMBER=@ACCOUNTNUMBER, @PROJECTCODE=@PROJECTCODE

      update dbo.DESIGNATION
      set ACCOUNTNUMBER = @ACCOUNTNUMBER,
          PROJECTCODE = @PROJECTCODE,
          CHANGEDBYID = @CHANGEAGENTID,
          DATECHANGED = @CURRENTDATE
      where ID = @DESIGNATIONID

    end


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

return 0;