using HuanMeng.DotNetCore.Base; using HuanMeng.MiaoYu.Code.Cache; using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu; using HuanMeng.MiaoYu.Model.Dto.Home; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HuanMeng.MiaoYu.Code.Chat { /// /// 聊天类 /// public class ChatBLL : MiaoYuBase { public ChatBLL(IServiceProvider serviceProvider) : base(serviceProvider) { } /// /// 删除聊天记录 /// /// 聊天id /// /// public async Task DelChatByIds(List id, int characterId) { //var charactersList = MiaoYuCache.CharactersList; //List list = _characterCache.GetCharacterFromCache(characterId); //var chatsToDelete = await Dao.daoDbMiaoYu.context.T_Chat.Where(t => id.Contains(t.Id)).ToListAsync(); //if (chatsToDelete.Count <= 0) //{ // throw new Exception(""); //} //var chatList = chatsToDelete.Where(t => t.UserId == _UserId && t.CharacterId == characterId && t.Type == 0).ToList(); //if (chatList.Count > 0) //{ // chatList.ForEach(t => t.Type = 2); //} //Dao.daoDbMiaoYu.context.SaveChanges(); return true; } /// /// 清空聊天记录 /// /// /// public async Task DelChat(int characterId) { //var tempList = await Dao.daoDbMiaoYu.context.T_Chat.Where(t => t.UserId == _UserId && t.CharacterId == characterId && t.IsDel == false).ToListAsync(); //if (tempList.Count > 0) //{ // tempList.ForEach(t => t.IsDel = true); //} //Dao.daoDbMiaoYu.context.SaveChanges(); return true; } } }