public ResponseObjectPackage<List<DictionaryField>> GetDictionaryFieldsViewModel(int dictionaryID)
        {
            List<DictionaryFieldModel> fields = this.GetDictionaryFieldsByDictionaryID(dictionaryID).GetDataOrExceptionIfError();
            DictionaryPrimaryKeyModel pk = new DictionaryPrimaryKeysLogic().GetDictionaryPrimaryKeyByDictionaryID(dictionaryID).GetDataOrExceptionIfError();
            List<DictionaryForeignKeyModel> fkList = new DictionaryForeignKeysLogic().GetDictionaryForeignKeysByDictionaryIDSource(dictionaryID).GetDataOrExceptionIfError();

            List<DictionaryField> fieldsWithPk = new List<DictionaryField>();
            foreach (DictionaryFieldModel field in fields)
            {
                DictionaryFieldModel foreignKey = fkList
                     .Where(fk => fk.dictionaryFieldIDSource == field.ID)
                     .Select(fks => new DictionaryFieldsLogic().GetDictionaryFieldByID(fks.dictionaryFieldIDDestination).GetDataOrExceptionIfError()).FirstOrDefault();
                bool isPrimaryKey = field.ID == pk.dictionaryFieldID;
                fieldsWithPk.Add(new DictionaryField(field, isPrimaryKey, foreignKey));
            }

            return new ResponseObjectPackage<List<DictionaryField>>() { resultData = fieldsWithPk };
        }
        public ResponsePackage SaveForeignKey(int dictionaryID, int dictionaryFieldIDSource)
        {
            int dictionaryFieldIDDestination = new DictionaryPrimaryKeysLogic().GetDictionaryPrimaryKeyByDictionaryID(dictionaryID)
                .GetDataOrExceptionIfError().dictionaryFieldID;

            RequestObjectPackage<DictionaryForeignKeyModel> request = new RequestObjectPackage<DictionaryForeignKeyModel>()
            {
                requestData = new DictionaryForeignKeyModel()
                {
                    ID = 0,
                    dictionaryFieldIDDestination = dictionaryFieldIDDestination,
                    dictionaryFieldIDSource = dictionaryFieldIDSource
                }
            };

            ResponsePackage response = new DBUtils().RunSqlAction(DictionaryForeignKeysRepository.SaveForeignKey, request);
            response.ThrowExceptionIfError();
            return response;
        }