Advertisement
N1K003

Untitled

Nov 3rd, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1.         public List<Message> GetMessages(String chatHash, Int32? count, Int32? lastMessageId, String order)
  2.         {
  3.             if (String.IsNullOrEmpty(chatHash))
  4.                 return null;
  5.  
  6.             IQueryable<Message> query = _messageRepository.GetAll()
  7.                     .Where(x => x.Chat.Hash == chatHash)
  8.                     .Include(x => x.User)
  9.                     .Include(x => x.Attachments);
  10.  
  11.             if (lastMessageId.HasValue && !String.IsNullOrEmpty(order))
  12.                 query = order == "DESC" ? query.Where(x => x.Id > lastMessageId.Value) : query.Where(x => x.Id < lastMessageId.Value);
  13.  
  14.             if (count.HasValue)
  15.                 query = query.Take(count.Value);
  16.  
  17.             return query.ToList();
  18.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement