public async Task <PrivateMessageDto> AddMessage(AddPrivateMessageDto message)
        {
            var messageToAdd = _mapper.Map <PrivateMessage>(message);

            _context.PrivateMessages.Add(messageToAdd);
            await _context.SaveChangesAsync();

            var result = _mapper.Map <PrivateMessageDto>(messageToAdd);

            return(result);
        }
        public async Task SendMessage(AddPrivateMessageDto message)
        {
            var connectionId = Context.ConnectionId;
            var from         = _userManager.GetUserById(connectionId);

            message.From = from.Login;
            var addedMessage = await _messageService.AddMessage(message);

            var receiver       = _userManager.GetUserByLogin(message.To);
            var toConnectionId = string.Empty;

            if (receiver != null)
            {
                toConnectionId = receiver.ConnectionId;
            }

            await Clients.Clients(toConnectionId, connectionId).MessageAdded(addedMessage);
        }