コード例 #1
0
        /// <summary>
        /// Receives the search result request and goes to th database looking for the information.
        /// </summary>
        /// <param name="request">A request model that contains the search parameters.</param>
        /// <returns></returns>
        public ActionResult SearchResults(FilmSearchModel model)
        {
            IList <Film> films = filmDAO.GetFilmsBetween(model.Genre, model.MinLength, model.MaxLength);

            /* Call the DAL and pass the values as a model back to the View */
            return(View(films));
        }
コード例 #2
0
        /// <summary>
        /// Receives the search result request and goes to th database looking for the information.
        /// </summary>
        /// <param name="request">A request model that contains the search parameters.</param>
        /// <returns></returns>
        ///

        public ActionResult SearchResult(FilmSearchModel films)
        {
            /* Call the DAL and pass the values as a model back to the View */

            var filmList = dal.GetFilmsBetween(films.Genre, films.MinLength, films.MaxLength);

            return(View("SearchResult", filmList)); //revisit
        }
コード例 #3
0
        public async Task <List <Film> > GetBySearchModelAsync(FilmSearchModel model)
        {
            var searcherResult = await _searchProvider.GetBySearchModelAsync(model);

            var explorerResult = await _explorerProvider.GetBySearchModelAsync(model);

            return(searcherResult.Concat(explorerResult).ToList());
        }
コード例 #4
0
        //public ActionResult Index(FilmSearchModel searchModel)
        //{
        //    IndexData model = new IndexData();

        //    model.Categorys = dal.GetCategoryNames();
        //    model.Films = dal.GetFilmsBetween(searchModel.Genre, searchModel.MaxLength, searchModel.MinLength);

        //    return View("Index", model);
        //}

        /// <summary>
        /// Receives the search result request and goes to th database looking for the information.
        /// </summary>
        /// <param name="request">A request model that contains the search parameters.</param>
        /// <returns></returns>
        ///
        public ActionResult SearchResult(FilmSearchModel searchModel)
        {
            IndexData model = new IndexData();

            model.Films     = dal.GetFilmsBetween(searchModel.Genre, searchModel.MaxLength, searchModel.MinLength);
            model.Categorys = dal.GetCategoryNames();
            return(View("SearchResult", model));
        }
コード例 #5
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));
        }
コード例 #6
0
 public async Task <List <Film> > GetBySearchModelAsync(FilmSearchModel model)
 {
     try
     {
         return((await _searcherClient.GetBySearchQueryAsync <Film>(model)).ToList());
     }
     catch
     {
         return(new List <Film>());
     }
 }
コード例 #7
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());
        }
コード例 #8
0
        public static FilmSearchModel Ensure(FilmSearchModel model)
        {
            var ensuredModel = new FilmSearchModel();

            ensuredModel.Duration = model.Duration;

            if (model.Name != null)
            {
                ensuredModel.Name = model.Name;
            }
            if (model.FilmMaker != null)
            {
                ensuredModel.FilmMaker = model.FilmMaker;
            }

            return(ensuredModel);
        }
コード例 #9
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>());
            }
        }
コード例 #10
0
        public async Task <IActionResult> GetAllBySearchQuery([FromQuery] FilmSearchModel filmModel)
        {
            var films = _mapper.Map <List <FilmModel> >(await _filmProvider.GetBySearchModelAsync(filmModel));

            return(Ok(films));
        }
コード例 #11
0
 public FilmFilterBuilder(FilmSearchModel searchModel)
 {
     SearchModel = searchModel;
     Filter      = PredicateBuilder.True <Film>();
 }
コード例 #12
0
        /// <summary>
        /// Receives the search result request and goes to th database looking for the information.
        /// </summary>
        /// <param name="request">A request model that contains the search parameters.</param>
        /// <returns></returns>
        public ActionResult SearchResult(FilmSearchModel model)
        {
            IList <Film> films = filmDAO.GetFilmsBetween(model.Genre, model.MinLength, model.MaxLength);

            return(View(films));
        }
コード例 #13
0
        // 1. Add a SearchResult Action
        public ActionResult SearchResult(FilmSearchModel filmSearch) //7. Add Model as a param
        {
            var films = dal.SearchFilms(filmSearch.Title, filmSearch.Description, filmSearch.ReleaseYear, filmSearch.MinLength, filmSearch.MaxLength, filmSearch.Rating);

            return(View("SearchResult", films)); //8. pass in the films as the model
        }