/// <summary> /// combined event for content / media / member /// </summary> /// <param name="sender"></param> /// <param name="savedEntities"></param> private void Saved(IService sender, IEnumerable <IContentBase> savedEntities) { foreach (IContentBase savedEntity in savedEntities) { // for each property foreach (PropertyType propertyType in savedEntity.PropertyTypes.Where(x => PickerPropertyValueConverter.IsPicker(x.PropertyEditorAlias))) { // create picker supplying all values Picker picker = new Picker(savedEntity.Id, propertyType.Alias, propertyType.DataTypeDefinitionId, savedEntity.GetValue(propertyType.Alias)); if (!string.IsNullOrWhiteSpace(picker.RelationTypeAlias)) { RelationMapping.UpdateRelationMapping( picker.ContextId, // savedEntity.Id picker.PropertyAlias, // propertyType.Alias picker.RelationTypeAlias, picker.GetDataTypePreValue("saveFormat").Value == "relationsOnly", picker.PickedIds.ToArray()); } } } }
/// <summary> /// combined event for content / media / member /// </summary> /// <param name="sender"></param> /// <param name="savedEntities"></param> private void Saved(IService sender, IEnumerable <IContentBase> savedEntities) { foreach (IContentBase savedEntity in savedEntities) { // for each property foreach (PropertyType propertyType in savedEntity.PropertyTypes.Where(x => PickerPropertyValueConverter.IsPicker(x.PropertyEditorAlias))) { // create picker supplying all values Picker picker = new Picker( savedEntity.Id, savedEntity.ParentId, propertyType.Alias, propertyType.DataTypeDefinitionId, propertyType.PropertyEditorAlias, savedEntity.GetValue(propertyType.Alias)); if (!string.IsNullOrWhiteSpace(picker.RelationTypeAlias)) { bool isRelationsOnly = picker.GetDataTypePreValue("saveFormat").Value == "relationsOnly"; if (isRelationsOnly) { if (picker.SavedValue == null) { picker.PickedKeys = new string[] { }; } else { // manually set on picker obj, so it doesn't then attempt to read picked keys from the database picker.PickedKeys = SaveFormat.GetKeys(picker.SavedValue.ToString()).ToArray(); // delete saved value (setting it to null) savedEntity.SetValue(propertyType.Alias, null); if (sender is IContentService) { ((IContentService)sender).Save((IContent)savedEntity, 0, false); } else if (sender is IMediaService) { ((IMediaService)sender).Save((IMedia)savedEntity, 0, false); } else if (sender is IMemberService) { ((IMemberService)sender).Save((IMember)savedEntity, false); } } } // update database RelationMapping.UpdateRelationMapping( picker.ContextId, // savedEntity.Id picker.PropertyAlias, // propertyType.Alias picker.RelationTypeAlias, isRelationsOnly, picker.PickedIds.ToArray()); } } } }
public IEnumerable <int> GetRelatedIds([FromUri] int contextId, [FromUri] string propertyAlias, [FromUri] string relationTypeAlias, [FromUri] bool relationsOnly) { return(RelationMapping.GetRelatedIds(contextId, propertyAlias, relationTypeAlias, relationsOnly)); }