Esempio n. 1
0
        public async Task <List <MessageResponse> > GetTopViewed(SkipTakeMessagesRequest request)
        {
            List <MessageResponse> messages = await _dbContext.Messages
                                              .Where(x => x.Views >= _minimumViewsTopCount)
                                              .OrderByDescending(x => x.Views)
                                              .Skip(request.Skip)
                                              .Take(request.Take)
                                              .Select(x => new MessageResponse()
            {
                CreatedAt     = x.CreatedAt,
                From          = x.User.Id,
                FromName      = x.User.UserName,
                Text          = x.Text,
                Location      = new Location(x.Location.X, x.Location.Y),
                DeleteAt      = x.DeleteAt,
                LikesCount    = x.UserLikedMessages.Count,
                Id            = x.Id,
                Place         = x.Place,
                Views         = x.Views,
                CommentsCount = x.Comments.Count,
                Photos        = x.MessageImages.Select(image => image.Id)
            })
                                              .ToListAsync();

            return(messages);
        }
Esempio n. 2
0
 public async Task <List <MessageResponse> > GetTopViewedMessages(SkipTakeMessagesRequest request)
 {
     return(await _messageService.GetTopViewed(request));
 }