Exemplo n.º 1
0
        public void AddUser(UserLableDTO u)
        {
            using (var client = new GraphClient(new Uri(_conn), _login, _pass))
            {
                client.Connect();

                client.Cypher.Create("(u:User { UserId: {p1},UserLogin: {p2}})")
                .WithParam("p1", u.UserId)
                .WithParam("p2", u.UserLogin)
                .ExecuteWithoutResults();
            }
        }
Exemplo n.º 2
0
 public void DeleteUser(UserLableDTO u)
 {
     using (var client = new GraphClient(new Uri(connectionString), login, pass))
     {
         client.Connect();
         client.Cypher
         .Match("(user1:User)-[r:Friends]-()")
         .Where("user1.User_Id = {p_id}")
         .WithParam("p_id", u.User_Id)
         .Delete("r,user1")
         .ExecuteWithoutResults();
     }
 }
Exemplo n.º 3
0
        public void AddUser(UserLableDTO u)
        {
            using (var client = new GraphClient(new Uri(connectionString), login, pass))
            {
                client.Connect();

                client.Cypher.Create("(u:User { User_Id: {p1},UserLogin: {p2},FisrtName: {p3},LastName: {p4} })")
                .WithParam("p1", u.User_Id)
                .WithParam("p2", u.User_Login)
                .WithParam("p3", u.User_Name)
                .WithParam("p4", u.User_Last_Name)
                .ExecuteWithoutResults();
            }
        }
Exemplo n.º 4
0
        public void AddUser(UserLableDTO u)
        {
            using (var client = new GraphClient(new Uri(connectionString), login, pass))
            {
                client.Connect();

                client.Cypher.Create("(u:User { UserID: {i},UserEmail: {e},FisrtName: {f},SurName: {s} })")
                .WithParam("i", u.User_Id)
                .WithParam("e", u.User_Email)
                .WithParam("f", u.User_Name)
                .WithParam("s", u.User_Surname)
                .ExecuteWithoutResults();
            }
        }
Exemplo n.º 5
0
 public void DeleteRelationship(UserLableDTO u1, UserLableDTO u2)
 {
     using (var client = new GraphClient(new Uri(connectionString), login, pass))
     {
         client.Connect();
         client.Cypher
         .Match("(user1:User)-[r:Friends]-(user2:User)")
         .Where("user1.User_Id = {p_id1}")
         .AndWhere("user2.User_Id = {p_id2}")
         .WithParam("p_id1", u1.User_Id)
         .WithParam("p_id2", u2.User_Id)
         .Delete("r")
         .ExecuteWithoutResults();
     }
 }
Exemplo n.º 6
0
 public void DeleteAllRelationships(UserLableDTO u1, UserLableDTO u2)
 {
     using (var client = new GraphClient(new Uri(_conn), _login, _pass))
     {
         client.Connect();
         client.Cypher
         .Match("(user1:User)-[r:Follower]-(user2:User)")
         .Where("user1.UserId = {p1}")
         .AndWhere("user2.UserId = {p2}")
         .WithParam("p1", u1.UserId)
         .WithParam("p2", u2.UserId)
         .Delete("r")
         .ExecuteWithoutResults();
     }
 }
Exemplo n.º 7
0
 public void AddFollow(UserLableDTO from, UserLableDTO to)
 {
     using (var client = new GraphClient(new Uri(_conn), _login, _pass))
     {
         client.Connect();
         client.Cypher
         .Match("(user1:User),(user2:User)")
         .Where("user1.UserId = {from}")
         .AndWhere("user2.UserId = {to}")
         .WithParam("from", from.UserId)
         .WithParam("to", to.UserId)
         .Create("(user1)-[:Follower]->(user2)")
         .ExecuteWithoutResults();
     }
 }
Exemplo n.º 8
0
 public bool HasRelationship(UserLableDTO u1, UserLableDTO u2)
 {
     using (var client = new GraphClient(new Uri(connectionString), login, pass))
     {
         client.Connect();
         var is_friends = client.Cypher
                          .Match("(user1:User)-[r:Friends]-(user2:User)")
                          .Where((UserLableDTO user1) => user1.User_Id == u1.User_Id)
                          .AndWhere((UserLableDTO user2) => user2.User_Id == u2.User_Id)
                          .Return(r => r.As <Friends>()).Results; // how to know type of relationship?
         if (is_friends.Count() > 0)
         {
             return(true);
         }
         return(false);
     }
 }
Exemplo n.º 9
0
 public bool HasAnyRelationship(UserLableDTO u1, UserLableDTO u2)
 {
     using (var client = new GraphClient(new Uri(_conn), _login, _pass))
     {
         client.Connect();
         var is_friends = client.Cypher
                          .Match("(user1:User)-[r:Follower]-(user2:User)")
                          .Where((UserLableDTO user1) => user1.UserId == u1.UserId)
                          .OrWhere((UserLableDTO user2) => user2.UserId == u2.UserId)
                          .Return(r => r.As <FollowerDTO>()).Results;
         if (is_friends.Count() > 0)
         {
             return(true);
         }
         return(false);
     }
 }
Exemplo n.º 10
0
 public UserLableDTO GetUserById(int id)
 {
     using (var client = new GraphClient(new Uri(_conn), _login, _pass))
     {
         client.Connect();
         var user = client.Cypher
                    .Match("(u:User)")
                    .Where((UserLableDTO u) => u.UserId == id)
                    .Return(u => u.As <UserLableDTO>())
                    .Results;
         UserLableDTO to_ret = new UserLableDTO()
         {
             UserId = id
         };
         foreach (var u in user)
         {
             to_ret.UserId    = u.UserId;
             to_ret.UserLogin = u.UserLogin;
         }
         return(to_ret);
     }
 }
Exemplo n.º 11
0
 public UserLableDTO GetUser(int id)
 {
     using (var client = new GraphClient(new Uri(connectionString), login, pass))
     {
         client.Connect();
         var user = client.Cypher
                    .Match("(u:User)")
                    .Where((UserLableDTO u) => u.User_Id == id)
                    .Return(u => u.As <UserLableDTO>())
                    .Results;
         UserLableDTO to_ret = new UserLableDTO()
         {
             User_Id = id
         };
         foreach (var u in user)
         {
             to_ret.User_Id        = u.User_Id;
             to_ret.User_Login     = u.User_Login;
             to_ret.User_Name      = u.User_Name;
             to_ret.User_Last_Name = u.User_Last_Name;
         }
         return(to_ret);
     }
 }
Exemplo n.º 12
0
 public int MinPathBetween(UserLableDTO u1, UserLableDTO u2)
 {
     return(this.MinPathBetween(u1.User_Id, u2.User_Id));
 }
Exemplo n.º 13
0
 public int PathBetween(UserLableDTO u1, UserLableDTO u2)
 {
     _userNeoDal.MinPathBetween(u1, u2);
 }
Exemplo n.º 14
0
 public bool Relationship(UserLableDTO u1, UserLableDTO u2)
 {
     _userNeoDal.HasRelationship(u1, u2);
 }
Exemplo n.º 15
0
 public void Follow(UserLableDTO u1, UserLableDTO u2)
 {
     _userNeoDal.AddRelationship(u1, u2);
 }