public static bool IsReverseRelationExists(this List <Relation> relations, Relation relation) { return (relations.FirstOrDefault( r => r.SourcePerson == relation.DestinationPerson && r.DestinationPerson == relation.SourcePerson && r.RelationType == relation.RelationType.GetReverseType()) != null); }
public static Relation GetReverseRelation(this Relation relation) { return(new Relation { SourcePerson = relation.DestinationPerson, DestinationPerson = relation.SourcePerson, RelationType = relation.RelationType.GetReverseType() }); }
public static Dal.Model.Relation ConvertToDalRelation(this Relation relation) { return(new Dal.Model.Relation { ParentId = relation.SourcePerson.Id, ChildId = relation.DestinationPerson.Id, RelationId = relation.RelationId, RelationType = (int)relation.RelationType }); }
public static Relation ConvertToViewRelation(this Dal.Model.Relation r, Func <int, Person> findPersonFunc) { var result = new Relation { RelationId = r.RelationId, SourcePerson = findPersonFunc(r.ParentId), DestinationPerson = findPersonFunc(r.ChildId), RelationType = (RelationType)r.RelationType }; return(result); }