Ejemplo n.º 1
0
        public async Task <PageList <Message> > GetMessagesForUser(ParaMessage para)
        {
            // var lastDate = System.DateTime.Now.AddMonths(-1);
            var result = _db.Message
                         .Include(p => p.Sender).ThenInclude(p => p.MemberPhoto)
                         .Include(p => p.Recipient).ThenInclude(p => p.MemberPhoto)
                         .AsQueryable();

            switch (para.MessageContainer)
            {
            case "Inbox":
                result = result.Where(p => p.RecipientId == para.UserId && p.RecipientDeleted == false && p.SendDate > _lastDate);
                break;

            case "Outbox":
                result = result.Where(p => p.SenderId == para.UserId && p.SenderDeleted == false && p.SendDate > _lastDate);
                break;

            default:
                result = result.Where(p => p.RecipientId == para.UserId &&
                                      p.RecipientDeleted == false && p.IsRead == false && p.SendDate > _lastDate);
                break;
            }

            result = result.OrderByDescending(p => p.SendDate);

            return(await PageList <Message> .CreateAsync(result, para.PageNumber, para.PageSize));
        }
Ejemplo n.º 2
0
 public Task <PageList <Message> > GetMessagesForUser(ParaMessage para)
 {
     throw new System.NotImplementedException();
 }