/// <summary> /// Gets a relation type by id /// </summary> /// <param name="id">The relation type ID.</param> /// <returns>Returns the <see cref="RelationTypeDisplay"/>.</returns> public ActionResult <RelationTypeDisplay?> GetById(int id) { var relationType = _relationService.GetRelationTypeById(id); if (relationType == null) { return(NotFound()); } var display = _umbracoMapper.Map <IRelationType, RelationTypeDisplay>(relationType); return(display); }
protected override ActionResult <MenuItemCollection> GetMenuForNode(string id, FormCollection queryStrings) { MenuItemCollection menu = _menuItemCollectionFactory.Create(); if (id == Constants.System.RootString) { //Create the normal create action menu.Items.Add <ActionNew>(LocalizedTextService, useLegacyIcon: false); //refresh action menu.Items.Add(new RefreshNode(LocalizedTextService, separatorBefore: true)); return(menu); } IRelationType?relationType = _relationService.GetRelationTypeById(int.Parse(id, CultureInfo.InvariantCulture)); if (relationType == null) { return(menu); } if (relationType.IsSystemRelationType() == false) { menu.Items.Add <ActionDelete>(LocalizedTextService, useLegacyIcon: false); } return(menu); }
public void SaveRelations(ContentRelationsDto contentRelations) { if (contentRelations.Sets == null || !contentRelations.Sets.Any()) { return; } var relations = relationService.GetByParentId(contentRelations.ParentId).ToList(); var parentEntity = entityService.Get(contentRelations.ParentId, contentRelations.ParentType); foreach (var set in contentRelations.Sets) { var typeId = set.RelationTypeId; var type = relationService.GetRelationTypeById(set.RelationTypeId); var setRelations = relations.Where(r => r.RelationTypeId == typeId); foreach (var removeRelation in setRelations) { relationService.Delete(removeRelation); } foreach (var relation in set.Relations) { if (relation.State == RelationStateEnum.Deleted || relation.Readonly) { continue; } var childEntity = entityService.Get(relation.ChildId, UmbracoObjectTypesExtensions.GetUmbracoObjectType(type.ChildObjectType)); relationService.Relate(parentEntity, childEntity, type); } } }
protected override IRelationType FindItem(Guid key) => relationService.GetRelationTypeById(key); // ??
public override IRelationType FindItem(int id) => relationService.GetRelationTypeById(id);