public List <List <Messages> > GetAllChats(int customUserId) { try { List <Chats> chatsInfo = _offlineMessagingDbContext.Chats.Where(x => x.SenderId == customUserId || x.ReceiverId == customUserId).ToList(); UsersAllChatsHelper usersAllChats = new UsersAllChatsHelper(); if (chatsInfo != null) { foreach (var chatInfo in chatsInfo) { List <Messages> messages = _offlineMessagingDbContext.Messages.Where(x => x.Chat.Id == chatInfo.Id && ((chatInfo.SenderId == customUserId && x.UploadDate >= chatInfo.SenderDeleteTime) || (chatInfo.ReceiverId == customUserId && x.UploadDate >= chatInfo.ReceiverDeleteTime))).ToList(); usersAllChats.AllChats.Add(messages); } } return(usersAllChats.AllChats); } catch (Exception ex) { PublicLogs publicLog = new PublicLogs(); publicLog.LogContent = ex.ToString(); publicLog.LogTime = DateTime.Now; InsertPublicLog(publicLog); return(null); } }
public List <List <Messages> > GetAllChats(int customUserId) { UsersAllChatsHelper usersAllChats = new UsersAllChatsHelper(); usersAllChats.AllChats = _customUserServices.GetAllChats(customUserId); return(usersAllChats.AllChats); }