Beispiel #1
0
        public async Task <IActionResult> GetAllBySearchQuery([FromQuery] FilmSearchModel filmSearchModel)
        {
            FilmSearchBuilder filmSearchBuilder = new FilmSearchBuilder(FilmSearchModel.Ensure(filmSearchModel));
            var tickets = await _filmService.Find(filmSearchBuilder.Build());

            tickets.Take(filmSearchModel.Count);

            return(Ok(tickets));
        }
Beispiel #2
0
        public async Task <List <Film> > GetBySearchModelCachedAsync(PagedFilmSearchModel model)
        {
            var films = await GetAllFromCacheAsync();

            var filter = new FilmFilterBuilder(FilmSearchModel.Ensure(model)).Build().Compile();

            return(films
                   .Where(filter)
                   .OrderBy(film => film.Name)
                   .Skip(model.Page > 1 ? (model.Page - 1) * PagedFilmSearchModel.PAGE_SIZE : 0)
                   .Take(PagedFilmSearchModel.PAGE_SIZE)
                   .ToList());
        }
Beispiel #3
0
        public async Task <List <Film> > GetBySearchModelAsync(FilmSearchModel model)
        {
            try
            {
                var filmIds = await GetFilmIdsAsync();

                var films = await GetFilmByIdsAsync(filmIds);

                var filter = new FilmFilterBuilder(FilmSearchModel.Ensure(model)).Build().Compile();

                return(films.Where(filter).ToList());
            }
            catch
            {
                return(new List <Film>());
            }
        }