public async Task Send(Message message) { try { message.EventId = Event.Message.GetHashCode(); message.CreatedDate = DateTime.Now; var userChat = await userChatAppService.GetByConnectionIdAsync(Context.ConnectionId); if (userChat != null) { message.UserChatId = userChat.UserChatId; await messageAppService.AddAsync(message); await messageAppService.SaveChangesAsync(); } await Clients.All.SendAsync("ReceiveMessage", message); } catch (Exception ex) { logger.LogError(ex, ex.Message); } }