private async Task <IPagedList <Message> > MarkAsRead(string currentUserId, string recipientId, IPagedList <Message> userMessages) { if ((userMessages.FirstOrDefault())?.RecipientId != currentUserId) { return(userMessages); } userMessages.TakeWhile(m => !m.IsRead).ToList().ForEach(m => m.MarkAsRead()); await database.Complete(); return(userMessages); }