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)
|
public Boolean IsParentOfChild(User parent, User child)
|
||||||
{
|
{
|
||||||
return child
|
return child
|
||||||
.Unfold(u => GetUserById(u.ParentId))
|
.Unfold(GetParent)
|
||||||
.Select(u => u.Id)
|
.Any(u => u.Id == parent.Id);
|
||||||
.Contains(parent.Id);
|
}
|
||||||
|
|
||||||
|
public User? GetParent(User u)
|
||||||
|
{
|
||||||
|
return GetUserById(u.ParentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public User? GetUserByEmail(String email) => Users.FirstOrDefault(u => u.Email == email);
|
public User? GetUserByEmail(String email) => Users.FirstOrDefault(u => u.Email == email);
|
||||||
|
|
Loading…
Reference in New Issue