﻿
DROP TABLE IF EXISTS tmpForSwitchDictionaryItemBase 
CREATE TABLE tmpForSwitchDictionaryItemBase(RegiID int, UjID int, TanevID int, C_NAME nvarchar(500), C_TYPE nvarchar(64))
DECLARE @TEMP_EnvironmentName nvarchar(1000) 
SET @TEMP_EnvironmentName = (SELECT TOP 1 [Value] 
FROM dev.EnvironmentInfo WHERE [Key] = 'Kornyezet')

IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
    -----  8372 ----- Iskolaőr -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8372, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'MunkakorTipus' AND DIB.C_NAME = N'Iskolaőr' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'MunkakorTipus' AND DIB.C_NAME = N'Iskolaőr' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
    -----  8372 ----- Iskolaőr -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8372, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'MunkakorTipus' AND DIB.C_NAME = N'Iskolaőr' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'MunkakorTipus' AND DIB.C_NAME = N'Iskolaőr' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
    -----  8372 ----- Iskolaőr -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8372, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'MunkakorTipus' AND DIB.C_NAME = N'Iskolaőr' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'MunkakorTipus' AND DIB.C_NAME = N'Iskolaőr' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
    -----  8372 ----- Iskolaőr -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8372, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'MunkakorTipus' AND DIB.C_NAME = N'Iskolaőr' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'MunkakorTipus' AND DIB.C_NAME = N'Iskolaőr' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
    -----  8373 ----- Órai feladat -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8373, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Órai feladat' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Órai feladat' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
    -----  8373 ----- Órai feladat -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8373, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Órai feladat' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Órai feladat' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
    -----  8373 ----- Órai feladat -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8373, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Órai feladat' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Órai feladat' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
    -----  8373 ----- Órai feladat -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8373, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Órai feladat' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Órai feladat' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
    -----  8374 ----- E-learning feladat -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8374, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'E-learning feladat' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'E-learning feladat' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
    -----  8374 ----- E-learning feladat -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8374, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'E-learning feladat' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'E-learning feladat' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
    -----  8374 ----- E-learning feladat -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8374, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'E-learning feladat' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'E-learning feladat' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
    -----  8374 ----- E-learning feladat -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8374, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'E-learning feladat' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'E-learning feladat' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
    -----  8375 ----- Teszt feladat -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8375, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Teszt feladat' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Teszt feladat' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
    -----  8375 ----- Teszt feladat -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8375, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Teszt feladat' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Teszt feladat' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
    -----  8375 ----- Teszt feladat -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8375, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Teszt feladat' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Teszt feladat' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
    -----  8375 ----- Teszt feladat -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8375, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Teszt feladat' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Teszt feladat' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'KK'
  BEGIN 
    -----  8376 ----- Feladatlap -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8376, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Feladatlap' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Feladatlap' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'NSZFH'
  BEGIN 
    -----  8376 ----- Feladatlap -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8376, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Feladatlap' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Feladatlap' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'HOI'
  BEGIN 
    -----  8376 ----- Feladatlap -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8376, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Feladatlap' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Feladatlap' AND DIB.TOROLT = 'F' 
END 

IF @TEMP_EnvironmentName = 'AZURE'
  BEGIN 
    -----  8376 ----- Feladatlap -----
    INSERT INTO tmpForSwitchDictionaryItemBase(RegiID, UjID, TanevID, C_NAME, C_TYPE)
    SELECT DIB.ID, 8376, DIB.C_TANEVID, DIB.C_NAME, DIB.C_TYPE
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Feladatlap' AND DIB.TOROLT = 'F' 
    UPDATE DIB SET 
    DIB.TOROLT = 'T' 
    FROM T_DICTIONARYITEMBASE DIB 
      WHERE DIB.C_TYPE = N'ErtekelesMod' AND DIB.C_NAME = N'Feladatlap' AND DIB.TOROLT = 'F' 
END 

 EXEC [dev].[uspCreateDictionaryItems] NULL, NULL 
 EXEC [dev].uspSwitchDictionaryItemBaseFromTmp  