Example #1
0
        public override async Task OnConnectedAsync()
        {
            var user = await _userService.GetloggedinUser();

            var requests = await _friendRequestService.CheckFriendRequest(user);

            var friends = await _friendService.GetFriends(user);

            var hasRequests = requests.Length == 0 ? false : true;
            await Clients.Caller.ReceiveFriendRequest(hasRequests, requests, friends);

            await base.OnConnectedAsync();
        }
Example #2
0
        public async Task <IActionResult> Index()
        {
            var loggedinUser = HttpContext.User;
            var user         = await _userService.GetloggedinUser();

            //var user = await _userService.GetloggedinUser(loggedinUser);
            var friends = await _friendService.GetFriends(user);

            var friendRequests = await _friendRequestService.CheckFriendRequest(user);

            _viewModelService.FriendsVM       = friends;
            _viewModelService.FriendRequestVM = friendRequests;
            await _profileImageService.GetFriendsProfileImagesAsync();

            return(View(_viewModelService));
        }
Example #3
0
        public async Task PostSearchResult([FromBody] TypeaheadUsersVM person)
        {
            var loggedinUser = await _userService.GetloggedinUser();

            var user = await _userService.GetUserByUserName(person.UserName);

            var friendRequestVM = new FriendRequestVM
            {
                FromUser     = loggedinUser.Id,
                ToUser       = person.Id,
                FromUserName = loggedinUser.UserName,
                ToUserName   = person.UserName
            };

            await _friendRequestService.SendFriendRequest(friendRequestVM);

            var friendRequests = await _friendRequestService.CheckFriendRequest(user);

            //var signalRModel = new FriendRequestVM[] { friendRequestVM };
            await _friendRequestHubContext.Clients.User(friendRequestVM.ToUser)
            .ReceiveFriendRequest(true, friendRequests);
        }