@@ -128,6 +128,27 @@ public IEnumerable<IRelation> GetByParentId(int id)
128
128
}
129
129
}
130
130
131
+ /// <summary>
132
+ /// Gets a list of <see cref="Relation"/> objects by their parent entity
133
+ /// </summary>
134
+ /// <param name="parent">Parent Entity to retrieve relations for</param>
135
+ /// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
136
+ public IEnumerable < IRelation > GetByParent ( IUmbracoEntity parent )
137
+ {
138
+ return GetByParentId ( parent . Id ) ;
139
+ }
140
+
141
+ /// <summary>
142
+ /// Gets a list of <see cref="Relation"/> objects by their parent entity
143
+ /// </summary>
144
+ /// <param name="parent">Parent Entity to retrieve relations for</param>
145
+ /// <param name="relationTypeAlias">Alias of the type of relation to retrieve</param>
146
+ /// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
147
+ public IEnumerable < IRelation > GetByParent ( IUmbracoEntity parent , string relationTypeAlias )
148
+ {
149
+ return GetByParent ( parent ) . Where ( relation => relation . RelationType . Alias == relationTypeAlias ) ;
150
+ }
151
+
131
152
/// <summary>
132
153
/// Gets a list of <see cref="Relation"/> objects by their child Id
133
154
/// </summary>
@@ -142,6 +163,27 @@ public IEnumerable<IRelation> GetByChildId(int id)
142
163
}
143
164
}
144
165
166
+ /// <summary>
167
+ /// Gets a list of <see cref="Relation"/> objects by their child Entity
168
+ /// </summary>
169
+ /// <param name="child">Child Entity to retrieve relations for</param>
170
+ /// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
171
+ public IEnumerable < IRelation > GetByChild ( IUmbracoEntity child )
172
+ {
173
+ return GetByChildId ( child . Id ) ;
174
+ }
175
+
176
+ /// <summary>
177
+ /// Gets a list of <see cref="Relation"/> objects by their child Entity
178
+ /// </summary>
179
+ /// <param name="child">Child Entity to retrieve relations for</param>
180
+ /// <param name="relationTypeAlias">Alias of the type of relation to retrieve</param>
181
+ /// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
182
+ public IEnumerable < IRelation > GetByChild ( IUmbracoEntity child , string relationTypeAlias )
183
+ {
184
+ return GetByChild ( child ) . Where ( relation => relation . RelationType . Alias == relationTypeAlias ) ;
185
+ }
186
+
145
187
/// <summary>
146
188
/// Gets a list of <see cref="Relation"/> objects by their child or parent Id.
147
189
/// Using this method will get you all relations regards of it being a child or parent relation.
@@ -422,7 +464,7 @@ public bool AreRelated(int parentId, int childId)
422
464
public bool AreRelated ( int parentId , int childId , string relationTypeAlias )
423
465
{
424
466
var relType = GetRelationTypeByAlias ( relationTypeAlias ) ;
425
- if ( relType == null )
467
+ if ( relType == null )
426
468
return false ;
427
469
428
470
return AreRelated ( parentId , childId , relType ) ;
@@ -445,6 +487,29 @@ public bool AreRelated(int parentId, int childId, IRelationType relationType)
445
487
}
446
488
}
447
489
490
+ /// <summary>
491
+ /// Checks whether two items are related
492
+ /// </summary>
493
+ /// <param name="parent">Parent entity</param>
494
+ /// <param name="child">Child entity</param>
495
+ /// <returns>Returns <c>True</c> if any relations exist between the entities, otherwise <c>False</c></returns>
496
+ public bool AreRelated ( IUmbracoEntity parent , IUmbracoEntity child )
497
+ {
498
+ return AreRelated ( parent . Id , child . Id ) ;
499
+ }
500
+
501
+ /// <summary>
502
+ /// Checks whether two items are related
503
+ /// </summary>
504
+ /// <param name="parent">Parent entity</param>
505
+ /// <param name="child">Child entity</param>
506
+ /// <param name="relationTypeAlias">Alias of the type of relation to create</param>
507
+ /// <returns>Returns <c>True</c> if any relations exist between the entities, otherwise <c>False</c></returns>
508
+ public bool AreRelated ( IUmbracoEntity parent , IUmbracoEntity child , string relationTypeAlias )
509
+ {
510
+ return AreRelated ( parent . Id , child . Id , relationTypeAlias ) ;
511
+ }
512
+
448
513
449
514
/// <summary>
450
515
/// Saves a <see cref="Relation"/>
0 commit comments