/// <summary> /// 保存聊天记录 /// </summary> /// <returns></returns> public async Task AddChatRecordContent(ChatMessage message) { var chatRecordContentInput = new ChatRecordContentInput { ReceiverId = message.ReceiverId, Message = message.Message }; await _tzChatRepository.AddChatRecordContent(chatRecordContentInput); }
/// <summary> /// 保存聊天记录到数据库 /// </summary> /// <param name="record"></param> /// <returns></returns> public async Task AddChatRecordContent(ChatRecordContentInput input) { var thisUserId = GetThisUserId; var chatRecord = _chatRecordRepository.GetAll() .FirstOrDefault(x => x.SenderId == GetThisUserId && x.ReceiverId == input.ReceiverId || x.SenderId == input.ReceiverId && x.ReceiverId == thisUserId); var chatRecordContent = new ChatRecordContent { ChatRecordId = chatRecord.Id, AscriptionUserId = thisUserId, SenderId = thisUserId, ReceiverId = input.ReceiverId, Message = input.Message }; await _chatRecordContentRepository.AddOrEditAndSaveAsyn(chatRecordContent); }