Ejemplo n.º 1
0
        private void addNewFriend(UserDTO user)
        {
            Console.WriteLine("Plese enter Login person you want to add to friendsList:");
            string   login   = Console.ReadLine();
            UserDTOn neoUser = _userManager.GetUserByMongoId(user.UserId);
            UserDTOn friend  = _userManager.GetUserByLogin(login);

            _userManager.AddFriend(neoUser, friend);
        }
Ejemplo n.º 2
0
 public void DeleteUser(UserDTOn user)
 {
     _client.Cypher
     .Match("(u:User)-[f:FRIEND]-()")
     .Where("u.userId = {user_id}")
     .WithParam("user_id", user.userId)
     .Delete("f,u")
     .ExecuteWithoutResults();
 }
Ejemplo n.º 3
0
 public void CreateUser(UserDTOn user)
 {
     _client.Cypher.Create("(u: User{ userId:{u1}, fisrtName:{u2}, lastName:{u3}, login:{u4}})")
     .WithParam("u1", user.userId)
     .WithParam("u2", user.firstName)
     .WithParam("u3", user.lastName)
     .WithParam("u3", user.login)
     .ExecuteWithoutResults();
 }
Ejemplo n.º 4
0
        private void deleteFriend(UserDTO user)
        {
            showFriends(getAllFriends(user));
            Console.WriteLine("Plese enter userId that you want to delete from your friend list:");
            int      id      = Convert.ToInt32(Console.ReadLine());
            UserDTOn neoUser = _userManager.GetUserByMongoId(user.UserId);
            UserDTOn friend  = _userManager.GetUserNeo4j(id);

            _userManager.RemoveFriend(neoUser, friend);
        }
Ejemplo n.º 5
0
 public void RemoveFriend(UserDTOn user, UserDTOn friend)
 {
     _client.Cypher
     .Match("(u1:User)-[f:FRIEND]-(u2:User)")
     .Where("u1.userId = {user_id1}")
     .AndWhere("u2.userId = {user_id2}")
     .WithParam("user_id1", user.userId)
     .WithParam("user_id2", friend.userId)
     .Delete("f")
     .ExecuteWithoutResults();
 }
Ejemplo n.º 6
0
 public void AddFriend(UserDTOn user, UserDTOn friend)
 {
     _client.Cypher
     .Match("(u1:User),(u2:User)")
     .Where("u1.userId = {user_id1}")
     .AndWhere("u2.userId = {user_id2}")
     .WithParam("user_id1", user.userId)
     .WithParam("user_id2", friend.userId)
     .Create("(u1)-[:Friends]->(u2)")
     .ExecuteWithoutResults();
 }
Ejemplo n.º 7
0
        public bool IsFriends(UserDTOn user1, UserDTOn user2)
        {
            var isFriends = _client.Cypher
                            .Match("(user1:User)-[r:FRIEND]-(user2:User)")
                            .Where((UserDTOn u1) => u1.userId == user1.userId)
                            .AndWhere((UserDTOn u2) => u2.userId == user2.userId)
                            .Return(f => f.As <Friends>()).Results;

            if (isFriends.Count() > 0)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 8
0
        public UserDTOn GetUser(int id)
        {
            var user = _client.Cypher
                       .Match("(u:User)")
                       .Where((UserDTOn u) => u.userId == id)
                       .Return(u => u.As <UserDTOn>())
                       .Results;
            UserDTOn result = new UserDTOn()
            {
                userId = id
            };

            foreach (var u in user)
            {
                result.userId    = u.userId;
                result.lastName  = u.lastName;
                result.login     = u.login;
                result.firstName = u.firstName;
            }
            return(result);
        }
Ejemplo n.º 9
0
 public bool IsFriends(UserDTOn user1, UserDTOn user2)
 {
     return(_userN.IsFriends(user1, user2));
 }
Ejemplo n.º 10
0
        public UserDTO GetUserByNeoId(int id)
        {
            UserDTOn user = _userN.GetUser(id);

            return(_userM.GetAllUsers().Where(u => u.Login == user.login).FirstOrDefault());
        }
Ejemplo n.º 11
0
 public void DeleteUser(UserDTOn userN, UserDTO userM)
 {
     _userM.DeleteUser(userM.UserId);
     _userN.DeleteUser(userN);
 }
Ejemplo n.º 12
0
 public void CreateUser(UserDTOn userN, UserDTO userM)
 {
     _userM.CreateUser(userM);
     _userN.CreateUser(userN);
 }
Ejemplo n.º 13
0
 public void AddFriend(UserDTOn user, UserDTOn friend)
 {
     _userN.AddFriend(user, friend);
 }
Ejemplo n.º 14
0
 public void UpdateUser(UserDTOn user)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 15
0
        private UserDTO createNewAccount()
        {
            UserDTO  user    = new UserDTO();
            UserDTOn userNeo = new UserDTOn();

            Console.WriteLine("\t\t~NEW USER~ ");
            Console.WriteLine("Input FirstName: ");
            string firstName = Console.ReadLine();

            Console.WriteLine("Input LastName: ");
            string lastName = Console.ReadLine();

            Console.WriteLine("Input Email:");
            user.Email = Console.ReadLine();

            user.FirstName    = firstName;
            user.LastName     = lastName;
            userNeo.firstName = firstName;
            userNeo.lastName  = lastName;

            bool   flag = true;
            string login;

            while (flag)
            {
                try
                {
                    Console.WriteLine("Input Login:"******"User with that login already exists!\nTry again!");
                }
            }
            Console.WriteLine("Input Password:");
            user.Password = Console.ReadLine();

            user.Interests = new List <string>();
            user.Friends   = new List <int>();

            _userManager.CreateUser(userNeo, user);
            return(user);
        }
Ejemplo n.º 16
0
 public void RemoveFriend(UserDTOn user, UserDTOn friend)
 {
     _userN.RemoveFriend(user, friend);
 }
Ejemplo n.º 17
0
 public void UpdateUser(UserDTO userM, UserDTOn userN)
 {
     _userM.UpdateUser(userM);
     _userN.UpdateUser(userN);
 }
Ejemplo n.º 18
0
        private void updating(UserDTO user)
        {
            UserDTOn neoUser = _userManager.GetUserByMongoId(user.UserId);
            bool     flag    = true;

            while (flag)
            {
                Console.WriteLine("\nPress number:\n\t1. to change FirstName;" +
                                  "\n\t2. to change LastName;\n\t3. to change Email;\n\t4. to add new Interests;" +
                                  "\n\t5. to change password;\n\t0.Exit\n");
                try
                {
                    int step = Convert.ToInt32(Console.ReadLine());
                    if (step == 0)
                    {
                        flag = false;
                    }
                    switch (step)
                    {
                    case 1:
                        Console.WriteLine("Input new FirstName: ");
                        string firstName = Console.ReadLine();
                        user.FirstName    = firstName;
                        neoUser.firstName = firstName;
                        break;

                    case 2:
                        Console.WriteLine("Input new LastName: ");
                        string lastName = Console.ReadLine();
                        user.LastName    = lastName;
                        neoUser.lastName = lastName;
                        break;

                    case 3:
                        Console.WriteLine("Input new Email: ");
                        user.Email = Console.ReadLine();
                        break;

                    case 4:
                        Console.WriteLine("Input new Interests: ");
                        string interests = Console.ReadLine();
                        user.Interests.Add(interests);
                        break;

                    case 5:
                        Console.WriteLine("Input new Password: "******"You've inputed wrong data.");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    Console.WriteLine("Try again, or input 0 to exit.");
                }
            }
            _userManager.UpdateUser(user, neoUser);
        }