private void HandleAddFriendClicked() { var newFriendship = new ClientFriendshipCreate { Status = RelationshipStatusConstants.PENDING, User1 = UserState.Value.ClientUsers.Where(x => x.Id == UserClaims.Claims.Single(x => x.Type == "sub").Value).Single(), User2 = _selectedUser }; Dispatcher.Dispatch(new SendFriendshipAction(newFriendship)); }
public async Task <IActionResult> SendFriendRequest([FromBody] ClientFriendshipCreate clientFriendship) { var friendship = _mapper.Map <Friendship>(clientFriendship); friendship.User1Id = clientFriendship.User1.Id; friendship.User2Id = clientFriendship.User2.Id; friendship.User2 = null; friendship.User1 = null; await _uow.FriendshipRepository.Insert(friendship); _logger.LogInformation("New friend request inserted"); var friendshipToSend = _mapper.Map <ClientFriendship>(clientFriendship); friendshipToSend.User1 = clientFriendship.User1; friendshipToSend.User2 = clientFriendship.User2; await _hubContext.Clients.All.SendAsync("friendRequest", _mapper.Map <ClientFriendship>(friendshipToSend)); return(Ok()); }
public SendFriendshipAction(ClientFriendshipCreate newFriendship) { NewFriendship = newFriendship; }