Rewrite IsParentOfChild even shorter :P
This commit is contained in:
parent
4812e371b0
commit
27b24b44a0
|
@ -31,9 +31,13 @@ public partial class Db
|
|||
public Boolean IsParentOfChild(User parent, User child)
|
||||
{
|
||||
return child
|
||||
.Unfold(u => GetUserById(u.ParentId))
|
||||
.Select(u => u.Id)
|
||||
.Contains(parent.Id);
|
||||
.Unfold(GetParent)
|
||||
.Any(u => u.Id == parent.Id);
|
||||
}
|
||||
|
||||
public User? GetParent(User u)
|
||||
{
|
||||
return GetUserById(u.ParentId);
|
||||
}
|
||||
|
||||
public User? GetUserByEmail(String email) => Users.FirstOrDefault(u => u.Email == email);
|
||||
|
|
Loading…
Reference in New Issue