Пример #1
0
        public async Task <string> RequestAddContact(RequestAddFriendContract contract)
        {
            var friendRequest = new FriendsRequest(contract.ReceiverId, contract.RequesterId);

            await _context.Set <FriendsRequest>().AddAsync(friendRequest);

            await _context.SaveChangesAsync();

            return("Successful");
        }
        public async Task <IActionResult> AddContact(RequestAddFriendContract request)
        {
            var userClaims = _claimsService.GetUserClaims();

            request.RequesterId = userClaims.Id;
            var result = await _contactService.RequestAddContact(request);

            var response = new ResponseMessage
            {
                Data      = result,
                IsSuccess = true
            };

            //   var connectionId = UserHandler.UserConnectionIds.First(x => x.UserId == userClaims.Id).ConnectionId;
            //   await _hubContext.Clients.Client(connectionId).SendAsync("reveiveContactRequest", "There's a friend request from " + request.RequesterId + " to " + request.ReceiverId);

            return(Ok(response));
        }