public async Task Send(string user, string message) { MessageInfo info = new MessageInfo(); info.EncodeMessage(message); long?UserId = await accountService.GetUserID(info.UserName); long?FriendID = await accountService.GetUserID(info.FriendName); if ((UserId != null) && (FriendID != null)) { await Task.Run(() => actionService.AddMessage((long)UserId, (long)FriendID, info.MessageText)); } await Clients.All.SendAsync("ReceiveMessage", user, message); }