public async Task <PagedList <MovieDTO> > GetUserRatingsAsync(SearchUserCriteraDTO searchCriteria) { Expression <Func <MovieDTO, bool> > finalQuery = r => r.Ratings.Where(p => p.User.Name == searchCriteria.UserName) .OrderByDescending(p => p.Value).Take(5).Any(); ICollection <MovieDTO> movies = await movieDbContext.Movies.GetItemsAsync( mapper, finalQuery, null, new List <Expression <Func <IQueryable <MovieDTO>, IIncludableQueryable <MovieDTO, object> > > >() { item => item.Include(genre => genre.Genres).Include(rating => rating.Ratings) });; return(PagedList <MovieDTO> .ToPagedList(movies, searchCriteria.PageNumber, searchCriteria.PageSize)); }
public async Task <ActionResult <PagedList <MovieDTO> > > GetUserRatingsAsync([FromQuery] SearchUserCriteraDTO searchCritera) { PagedList <MovieDTO> pagedMovies = await movieRepository.GetUserRatingsAsync(searchCritera); if (pagedMovies != null && pagedMovies.Count > 0) { return(pagedMovies); } return(NotFound()); }