diff --git a/src/Umbraco.Core/Services/IRelationService.cs b/src/Umbraco.Core/Services/IRelationService.cs index a629dc331d..cf89ce0540 100644 --- a/src/Umbraco.Core/Services/IRelationService.cs +++ b/src/Umbraco.Core/Services/IRelationService.cs @@ -182,6 +182,14 @@ namespace Umbraco.Core.Services /// Returns True if any relations exists with the given Id, otherwise False bool IsRelated(int id); + /// + /// Checks whether two items are related + /// + /// Id of the Parent relation + /// Id of the Child relation + /// Returns True if any relations exists with the given Ids, otherwise False + bool AreRelated(int parentId, int childId); + /// /// Saves a /// diff --git a/src/Umbraco.Core/Services/RelationService.cs b/src/Umbraco.Core/Services/RelationService.cs index 869fe8ab4d..2f82af9fc9 100644 --- a/src/Umbraco.Core/Services/RelationService.cs +++ b/src/Umbraco.Core/Services/RelationService.cs @@ -397,6 +397,21 @@ namespace Umbraco.Core.Services } } + /// + /// Checks whether two items are related + /// + /// Id of the Parent relation + /// Id of the Child relation + /// Returns True if any relations exists with the given Ids, otherwise False + public bool AreRelated(int parentId, int childId) + { + using (var repository = _repositoryFactory.CreateRelationRepository(_uowProvider.GetUnitOfWork())) + { + var query = new Query().Where(x => x.ParentId == parentId && x.ChildId == childId); + return repository.GetByQuery(query).Any(); + } + } + /// /// Saves a ///