Exemplo n.º 1
0
        public ActionResult SimpleLikes(bool setup = false)
        {
            LikesModel model = new LikesModel();
            if (setup)
                SetupGraphNodes();

            return View(model);
        }
Exemplo n.º 2
0
 public ActionResult SimpleLikes(LikesModel model)
 {
     //create relationships
     _neo4jClient.Cypher
         .Match("(person:PERSON)", "(thing:THING)")
         .Where((Person person) => person.id == model.Person)
         .AndWhere((Thing thing) => thing.id == model.Thing)
         .CreateUnique("person-[:LIKES]->thing")
         .ExecuteWithoutResults();
     return View(model);
 }
Exemplo n.º 3
0
        private void SetupGraphNodes()
        {
            ClearGraph();
            _neo4jClient.Connect();
            int id = 0;
            LikesModel model = new LikesModel();
            foreach(var person in model.Persons)
            {                
                int.TryParse(person.Value, out id);
                var personNode = new Person { id = id, name = person.Text};
                _neo4jClient.Cypher
                    .Merge("(person:PERSON {id: {id}, name: {name} })")
                    .OnCreate()
                    .Set("person = {personNode}")
                    .WithParams(new
                    {
                        id = id,
                        name = person.Text,
                        personNode
                    }).ExecuteWithoutResults();
            }

            foreach (var thing in model.Things)
            {
                int.TryParse(thing.Value, out id);
                var thingNode = new Thing { id = id, name = thing.Text };
                _neo4jClient.Cypher
                    .Merge("(thing:THING {id: {id}, name: {name} })")
                    .OnCreate()
                    .Set("thing = {thingNode}")
                    .WithParams(new
                    {
                        id = id,
                        name = thing.Text,
                        thingNode
                    }).ExecuteWithoutResults();
            }
        }