示例#1
0
        public MovieDBResponse GetAll()
        {
            _logger.LogDebug("Getting all Movie Records");
            var response = new MovieDBResponse();

            response.Count  = _context.Movies.Count();
            response.Movies = _context.Movies.ToList();

            return(response);
        }
示例#2
0
        public MovieDBResponse GetAll(MovieQuery query)
        {
            _logger.LogDebug("Getting filtered Movie Records with filter: {0} and category {1}", query.SearchFilter, query.Categories);
            var response = new MovieDBResponse();

            var result = _context.Movies as IQueryable <MovieDB>;

            if (!string.IsNullOrEmpty(query.SearchFilter))
            {
                result = result.Where(m => m.Title.Contains(query.SearchFilter));
            }

            if (query.Categories != null && query.Categories.Any())
            {
                result = result.Where(m => query.Categories.Contains(m.Category));
            }

            response.Count = result.Count();

            response.Movies = result.OrderBy(m => m.Title)
                              .Take(query.Take.Value).Skip(query.Skip.Value);

            return(response);
        }