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); }
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(); }
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(); }
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); }
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(); }
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(); }
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); }
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); }
public bool IsFriends(UserDTOn user1, UserDTOn user2) { return(_userN.IsFriends(user1, user2)); }
public UserDTO GetUserByNeoId(int id) { UserDTOn user = _userN.GetUser(id); return(_userM.GetAllUsers().Where(u => u.Login == user.login).FirstOrDefault()); }
public void DeleteUser(UserDTOn userN, UserDTO userM) { _userM.DeleteUser(userM.UserId); _userN.DeleteUser(userN); }
public void CreateUser(UserDTOn userN, UserDTO userM) { _userM.CreateUser(userM); _userN.CreateUser(userN); }
public void AddFriend(UserDTOn user, UserDTOn friend) { _userN.AddFriend(user, friend); }
public void UpdateUser(UserDTOn user) { throw new NotImplementedException(); }
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); }
public void RemoveFriend(UserDTOn user, UserDTOn friend) { _userN.RemoveFriend(user, friend); }
public void UpdateUser(UserDTO userM, UserDTOn userN) { _userM.UpdateUser(userM); _userN.UpdateUser(userN); }
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); }