Ejemplo n.º 1
0
        public async Task AddFriend(FriendRequestSent friend)
        {
            RineUser receiver = _context.Users.First(u => u.UserName == friend.Receiver);
            RineUser sender   = _context.Users.First(u => u.UserName == Context.User.Identity.Name);

            DateTime now = DateTime.Now;

            if (sender != null && receiver != null)
            {
                var friendship = new Friendship
                {
                    UserRecvId    = receiver.Id,
                    UserRequestId = sender.Id,
                    Description   = friend.Description,
                    Status        = FriendshipStatus.Pending,
                };
                _context.Add(friendship);
                await _context.SaveChangesAsync();

                await Clients.User(receiver.UserName).NotifyFriendRequests(new FriendRequestRecv
                {
                    Id          = friendship.Id,
                    Sender      = sender.UserName,
                    Created     = now,
                    Description = friend.Description,
                });
            }
        }
Ejemplo n.º 2
0
 public void Handle(FriendRequestSent message)
 {
     if (this._user == null || message.UserId != this._user.id)
     {
         return;
     }
     this._user.friend_status = 1;
     this.NotifySubscribeProperties();
 }
Ejemplo n.º 3
0
 public void Handle(FriendRequestSent message)
 {
     this.CheckSubscriptionFromPostForId(message.UserId);
 }
 public void Handle(FriendRequestSent message)
 {
   this.UpdateUserFriendStatus(message.UserId, 1);
 }