public ActionResult <List <Edge> > AddNode([FromBody] string idNode) { //TODO -> refactor var edges = new List <Edge>(); foreach (var node in mapState.map[mapState.activeIndex].ToList()) { var sq = new EdgeSearchQuery() { SourceAccount = idNode, DestinationAccount = node }; edges.AddRange(elasticService.Search <Edge>(sq)); var sq1 = new EdgeSearchQuery() { SourceAccount = node, DestinationAccount = idNode }; edges.AddRange(elasticService.Search <Edge>(sq1)); } mapState.map[mapState.activeIndex].Add(idNode); return(Ok(edges)); }
public ActionResult <Tuple <HashSet <Node>, HashSet <Edge> > > Expand([FromBody] ExpandQuery expandQuery) //informing front { var output = new List <Tuple <HashSet <Node>, HashSet <Edge> > >(); var nodes = new HashSet <Node>(); var edges = new HashSet <Edge>(); var accs = String.Join(' ', expandQuery.Accounts); var incomingEdgeSearchQuery = new EdgeSearchQuery() { DestinationAccount = accs }; var outcomingEdgeSearchQuery = new EdgeSearchQuery() { SourceAccount = accs }; incomingEdgeSearchQuery.SetFiltersFrom(expandQuery); outcomingEdgeSearchQuery.SetFiltersFrom(expandQuery); var nodesId = new HashSet <string>(); foreach (var edge in elasticService.Search <Edge>(incomingEdgeSearchQuery)) { nodesId.Add(edge.SourceAccount); edges.Add(edge); } foreach (var edge in elasticService.Search <Edge>(outcomingEdgeSearchQuery)) { nodesId.Add(edge.DestinationAccount); edges.Add(edge); } nodes.UnionWith(elasticService .Search <Node>( new NodeSearchQuery() { AccountId = String.Join(' ', nodesId) } ) ); return(new Tuple <HashSet <Node>, HashSet <Edge> >(nodes, edges)); }