Example #1
0
        public IActionResult AddFriend(string receiverEmail, string receiverId)
        {
            var email = HttpContext.Session.GetString("email");

            DbHelper.AddFriend(email, receiverEmail);
            Console.Write(email);

            return(Redirect($"/User/Profile/{receiverId}"));
        }
Example #2
0
        private static void AddFriend(NetworkStream stream)
        {
            const int BufferSize = 128;

            byte[] commandResponce = new byte[BufferSize];
            stream.Read(commandResponce, 0, BufferSize);
            string email  = Encoding.UTF8.GetString(commandResponce);
            int    userId = DbHelper.IsUser(email);

            stream.Write(Encoding.UTF8.GetBytes(userId.ToString()), 0, userId.ToString().Length);
            if (userId >= 0)
            {
                commandResponce = new byte[BufferSize];
                stream.Read(commandResponce, 0, BufferSize);
                string FromEmail    = (Encoding.UTF8.GetString(commandResponce));
                int    FromId       = DbHelper.IsUser(FromEmail);
                bool   isFriendship = DbHelper.IsFriendship(FromId, userId);
                if (!isFriendship)
                {
                    DbHelper.AddFriend(FromId, userId);
                    Console.WriteLine($"->Added new friend: {email} to user:{FromEmail}");
                }
            }
        }
Example #3
0
 public static void AddFriend(string requesterEmail, string receiverEmail)
 {
     DbHelper.AddFriend(requesterEmail, receiverEmail);
 }
 private void CreateFriendRequest()
 {
     DbHelper.AddFriend("tim@tim", "*****@*****.**");
 }
Example #5
0
 public void TestSetup()
 {
     controller = new UserController();
     DbHelper.ClearCollection("friend");
     DbHelper.AddFriend("*****@*****.**", "*****@*****.**");
 }