public async Task <PagedList <Message> > GetMessagesForUser(MessageParams messageParams) { IEnumerable <Message> messages; switch (messageParams.MessageContainer) { case "Inbox": messages = await _messagesDataContext.GetInbox(messageParams.UserId); break; case "Outbox": messages = await _messagesDataContext.GetOutbox(messageParams.UserId); break; default: messages = await _messagesDataContext.GetUnread(messageParams.UserId); break; } messages = messages.OrderByDescending(d => d.MessageSent); return(PagedList <Message> .Create(messages, messageParams.PageNumber, messageParams.PageSize)); }
public async Task <ICollection <Message> > MessagesReceived() { if (_messagesDataContext != null) { return(await _messagesDataContext.GetInbox(Id)); } else { return(new List <Message>()); } }