예제 #1
0
        public override void UpdateFieldSettings(string fieldType, string fieldName, SettingsDictionary settingsDictionary, IUpdateModel updateModel)
        {
            if (fieldType != "ReferenceField")
            {
                return;
            }
            var model = new ReferenceFieldSettings();

            if (updateModel.TryUpdateModel(model, "ReferenceFieldSettings", null, null))
            {
                if (model.QueryId <= 0)
                {
                    model.QueryId = CreateQuery(model.ContentTypeName);
                }

                if (model.RelationshipId <= 0)
                {
                    var entityName = settingsDictionary["EntityName"];
                    model.RelationshipId = _relationshipService.CreateOneToManyRelationship(fieldName, model.RelationshipName, model.ContentTypeName, entityName);
                }

                UpdateSettings(model, settingsDictionary, "ReferenceFieldSettings");
                settingsDictionary["ReferenceFieldSettings.ContentTypeName"]  = model.ContentTypeName;
                settingsDictionary["ReferenceFieldSettings.RelationshipName"] = model.RelationshipName;
                settingsDictionary["ReferenceFieldSettings.DisplayAsLink"]    = model.DisplayAsLink.ToString();
                settingsDictionary["ReferenceFieldSettings.QueryId"]          = model.QueryId.ToString(CultureInfo.InvariantCulture);
                settingsDictionary["ReferenceFieldSettings.RelationshipId"]   = model.RelationshipId.ToString(CultureInfo.InvariantCulture);
            }
        }