private XElement SerializeRelations(IRelationType item) { var relations = relationService.GetAllRelationsByRelationType(item.Id); var node = new XElement("Relations"); foreach (var relation in relations.OrderBy(x => x.ChildId).OrderBy(x => x.ParentId)) { var relationNode = new XElement("Relation"); var entities = relationService.GetEntitiesFromRelation(relation); if (entities.Item1 != null) { relationNode.Add(new XElement("Parent", entities.Item1.Key)); } if (entities.Item2 != null) { relationNode.Add(new XElement("Child", entities.Item2.Key)); } node.Add(relationNode); } return(node); }
// Umbraco.Code.MapAll -ParentName -ChildName private void Map(IRelation source, RelationDisplay target, MapperContext context) { target.ChildId = source.ChildId; target.Comment = source.Comment; target.CreateDate = source.CreateDate; target.ParentId = source.ParentId; var entities = _relationService.GetEntitiesFromRelation(source); target.ParentName = entities.Item1.Name; target.ChildName = entities.Item2.Name; }
// Umbraco.Code.MapAll -ParentName -ChildName private void Map(IRelation source, RelationDisplay target, MapperContext context) { target.ChildId = source.ChildId; target.Comment = source.Comment; target.CreateDate = source.CreateDate; target.ParentId = source.ParentId; Tuple <IUmbracoEntity, IUmbracoEntity>?entities = _relationService.GetEntitiesFromRelation(source); if (entities is not null) { target.ParentName = entities.Item1.Name; target.ChildName = entities.Item2.Name; } }