public bool CheckOwnershipOfParentProject(Project pro, Guid userId) { if (pro == null || userId == Guid.Empty) { return(false); } if (projectAncestors.ContainsKey(pro.Id)) { return(GetAvailableProjectAncestors(pro.Id).Any(x => x.OwnerUserId == userId)); } if (pro.ParentProjectId != null && pro.ParentProjectId != Guid.Empty) { var parent = projects.FirstOrDefault(x => x.Id == pro.ParentProjectId.Value); if (parent != null) { return(parent.OwnerUserId == userId || GetAvailableProjectAncestors(parent.Id).Any(x => x.OwnerUserId == userId)); } } return(false); }