Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<Message> GetMessages(String chatHash, Int32? count, Int32? lastMessageId, String order)
- {
- if (String.IsNullOrEmpty(chatHash))
- return null;
- if (lastMessageId.HasValue)
- {
- if (String.IsNullOrEmpty(order) || (order == "DESC"))
- {
- if (count.HasValue)
- return _messageRepository.GetAll()
- .Where(x => (x.Chat.Hash == chatHash) && (x.Id > lastMessageId.Value))
- .Include(x => x.Attachments).Include(x => x.User)
- .OrderByDescending(x => x.Id)
- .Take(count.Value)
- .ToList();
- return _messageRepository.GetAll()
- .Where(x => (x.Chat.Hash == chatHash) && (x.Id > lastMessageId.Value))
- .Include(x => x.Attachments).Include(x => x.User)
- .OrderByDescending(x => x.Id)
- .ToList();
- }
- if (count.HasValue)
- return _messageRepository.GetAll()
- .Where(x => (x.Chat.Hash == chatHash) && (x.Id > lastMessageId.Value))
- .Include(x => x.Attachments).Include(x => x.User)
- .Take(count.Value)
- .ToList();
- return _messageRepository.GetAll()
- .Where(x => (x.Chat.Hash == chatHash) && (x.Id > lastMessageId.Value))
- .Include(x => x.Attachments).Include(x => x.User)
- .ToList();
- }
- if (count.HasValue)
- return _messageRepository.GetAll()
- .Where(x => x.Chat.Hash == chatHash)
- .Include(x => x.Attachments).Include(x => x.User)
- .OrderByDescending(x => x.Id)
- .Take(count.Value)
- .ToList();
- return _messageRepository.GetAll()
- .Where(x => x.Chat.Hash == chatHash)
- .Include(x => x.Attachments).Include(x => x.User)
- .ToList();
- }
Add Comment
Please, Sign In to add comment