-- DATAPUMP FOR EMAIL CONFIG FOR ALL TENANTS

IF NOT EXISTS(
	SELECT TOP 1 1
	  FROM [Settings] ST
	 WHERE ST.[KeyName] = 'AzureAppClientId')
BEGIN
	INSERT INTO [Settings]
	([KeyName],
	[KeyValue])
	VALUES
	('AzureAppClientId',
	'4401f53c-b27d-419f-b682-89eda0b4e173'
	)
END
GO


IF NOT EXISTS(
	SELECT TOP 1 1
	  FROM [Settings] ST
	 WHERE ST.[KeyName] = 'EmailAzureAppTenantId')
BEGIN
	INSERT INTO [Settings]
	([KeyName],
	[KeyValue])
	VALUES
	('EmailAzureAppTenantId',
	'3c70566a-c054-496d-bc9d-9a6184aa8e70'
	)
END
GO

IF NOT EXISTS(
	SELECT TOP 1 1
	  FROM [Settings] ST
	 WHERE ST.[KeyName] = 'GraphAPIFromEmailId')
BEGIN
	INSERT INTO [Settings]
	([KeyName],
	[KeyValue])
	VALUES
	('GraphAPIFromEmailId',
	'register@keyhouse365.com'
	)
END
GO


IF NOT EXISTS(
	SELECT TOP 1 1
	  FROM [Settings] ST
	 WHERE ST.[KeyName] = 'AzureAppClientSecret')
BEGIN
	INSERT INTO [Settings]
	([KeyName],
	[KeyValue])
	VALUES
	('AzureAppClientSecret',
	'2x68Q~nhbAGtgAjBrHSVecEsSmxg29qsO.FHAcxq'
	)
END
GO

IF EXISTS(
	SELECT TOP 1 1
	  FROM [Settings] ST
	 WHERE ST.[KeyName] = 'AzureAppClientSecret')
BEGIN
	UPDATE [SET]
	   SET [KeyValue] = '2x68Q~nhbAGtgAjBrHSVecEsSmxg29qsO.FHAcxq'
	  FROM [dbo].[Settings] [SET]
	 WHERE [SET].[KeyName] = 'AzureAppClientSecret'
END
GO
