N1K003

Untitled

Nov 3rd, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.31 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.             if (lastMessageId.HasValue)
  7.             {
  8.                 if (String.IsNullOrEmpty(order) || (order == "DESC"))
  9.                 {
  10.                     if (count.HasValue)
  11.                         return _messageRepository.GetAll()
  12.                                 .Where(x => (x.Chat.Hash == chatHash) && (x.Id > lastMessageId.Value))
  13.                                 .Include(x => x.Attachments).Include(x => x.User)
  14.                                 .OrderByDescending(x => x.Id)
  15.                                 .Take(count.Value)
  16.                                 .ToList();
  17.  
  18.                     return _messageRepository.GetAll()
  19.                             .Where(x => (x.Chat.Hash == chatHash) && (x.Id > lastMessageId.Value))
  20.                             .Include(x => x.Attachments).Include(x => x.User)
  21.                             .OrderByDescending(x => x.Id)
  22.                             .ToList();
  23.                 }
  24.  
  25.                 if (count.HasValue)
  26.                     return _messageRepository.GetAll()
  27.                             .Where(x => (x.Chat.Hash == chatHash) && (x.Id > lastMessageId.Value))
  28.                             .Include(x => x.Attachments).Include(x => x.User)
  29.                             .Take(count.Value)
  30.                             .ToList();
  31.  
  32.                 return _messageRepository.GetAll()
  33.                         .Where(x => (x.Chat.Hash == chatHash) && (x.Id > lastMessageId.Value))
  34.                         .Include(x => x.Attachments).Include(x => x.User)
  35.                         .ToList();
  36.             }
  37.  
  38.             if (count.HasValue)
  39.                 return _messageRepository.GetAll()
  40.                         .Where(x => x.Chat.Hash == chatHash)
  41.                         .Include(x => x.Attachments).Include(x => x.User)
  42.                         .OrderByDescending(x => x.Id)
  43.                         .Take(count.Value)
  44.                         .ToList();
  45.  
  46.             return _messageRepository.GetAll()
  47.                     .Where(x => x.Chat.Hash == chatHash)
  48.                     .Include(x => x.Attachments).Include(x => x.User)
  49.                     .ToList();
  50.         }
Add Comment
Please, Sign In to add comment