Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public IQueryable<Node> GetNodes(int parentNodeId, List<int> orgIds)
- {
- var orgNodeIds = new List<int>();
- var docs = _db.Documents.Select(ldoc => Mapper.Map<LinqDocument, Document>(ldoc));
- foreach(var doc in docs)
- {
- foreach(var docOrgId in doc.DocumentOrganisations)
- {
- foreach(var orgId in orgIds)
- {
- if(docOrgId.OrganisationId == orgId)
- {
- if(!orgNodeIds.Contains(doc.NodeId))
- orgNodeIds.Add(doc.NodeId);
- }
- }
- }
- }
- var nodes = _db.Nodes.Where(x => x.ParentId == parentNodeId).Select(lnode => Mapper.Map<LinqNode, Node>(lnode));
- var returnNodes = new List<Node>();
- foreach(var node in nodes)
- {
- if (includeThis(orgNodeIds, node)) { returnNodes.Add(node); }
- else {
- foreach (var childNode in GetNodes(node.NodeId))
- {
- if (includeThis(orgNodeIds, childNode)) { returnNodes.Add(node); }
- else
- {
- foreach (var subChildNode in GetNodes(node.NodeId))
- {
- if (includeThis(orgNodeIds, childNode)) { returnNodes.Add(node); }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment