﻿SET IDENTITY_INSERT [T_CONFIGTIPUS] ON
---------------------------------------
INSERT INTO T_CONFIGTIPUS ([ID], [C_CONFIG], [C_MODUL], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR], [ELOZOTANEVIREKORDID])
VALUES
	(17, 'IsEnabled', 'Konyvtar', 'F', 0, GETDATE(), GETDATE(), 0, 0, NULL)
	,(18, 'Url', 'Konyvtar', 'F', 0, GETDATE(), GETDATE(), 0, 0, NULL)
---------------------------------------
SET IDENTITY_INSERT [T_CONFIGTIPUS] OFF

DECLARE @EnvironmentName nvarchar(1000)
	SET @EnvironmentName = (SELECT TOP 1 [Value] FROM dev.EnvironmentInfo WHERE [Key] = 'Kornyezet')

DECLARE @konyvtarUrl nvarchar(255) = CASE @EnvironmentName
  WHEN 'AZURE' THEN 'https://konyvtar-ema.e-kreta.hu/sso'
  WHEN 'HOI' THEN 'https://konyvtar-hoi.e-kreta.hu/sso' 
  WHEN 'KK' THEN 'https://konyvtar-kk.e-kreta.hu/sso'
  WHEN 'NSZFH' THEN 'https://konyvtar-nszfh.e-kreta.hu/sso'
  WHEN 'NSZFH-EMA' THEN 'https://konyvtar-nszfh-ema.e-kreta.hu/sso'
END

DECLARE @konyvtarIsEnabled nvarchar(255) = CASE WHEN @EnvironmentName IN ('AZURE','HOI','KK','NSZFH','NSZFH-EMA') THEN 'true' ELSE 'false' END

INSERT INTO T_INTEZMENYCONFIG ([C_ERTEK], [C_CONFIGTIPUSID], [C_INTEZMENYID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR], [ELOZOTANEVIREKORDID])
	SELECT @konyvtarIsEnabled, 17, i.ID, 'F', 0, GETDATE(), GETDATE(), 0, 0, NULL FROM T_INTEZMENY i WHERE i.TOROLT = 'F'
​
INSERT INTO T_INTEZMENYCONFIG ([C_ERTEK], [C_CONFIGTIPUSID], [C_INTEZMENYID], [TOROLT], [SERIAL], [LASTCHANGED], [CREATED], [MODIFIER], [CREATOR], [ELOZOTANEVIREKORDID])
	SELECT @konyvtarUrl, 18, i.ID, 'F', 0, GETDATE(), GETDATE(), 0, 0, NULL FROM T_INTEZMENY i WHERE i.TOROLT = 'F'
