예제 #1
0
        public ActionResult Search(string searchQuery, int page = 1, int perPage = 9)
        {
            if (_fullTextSearch == null)
            {
                _fullTextSearch = new FullTextSearchService(DocumentSession);
            }
            var books = _fullTextSearch.Search(searchQuery);

            ViewBag.Title = string.Format("Search Results for \"{0}\"", searchQuery);
            var bookInformations = new StaticPagedList <BookInformation>(books.Skip((page - 1) * perPage).Take(perPage)
                                                                         .Select(book => new BookInformation(book))
                                                                         .ToList(), page, perPage, books.Count);

            if (books.Count() == 1)
            {
                return(RedirectToAction("Details", new { id = bookInformations.First().Model.Id }));
            }
            if (!bookInformations.Any())
            {
                TempData["flashNotice"] = NoBooksFoundTxtSearch;
            }
            ViewBag.HideFilter  = true;
            ViewBag.SearchQuery = searchQuery;
            return(View("List", new FilterInformation(bookInformations)));
        }
예제 #2
0
 public CarAdService(
     DbContext db,
     IPublisher publisher,
     IFullTextSearch fullTextSearch,
     IMapper mapper)
     : base(db, publisher)
 {
     this.fullTextSearch = fullTextSearch;
     this.mapper         = mapper;
 }
        public CarAdsController(
            ICarAdService carAds,
            IDealerService dealers,
            ICategoryService categories,
            IManufacturerService manufacturers,
            IFullTextSearch fullTextSearch,
            ICurrentUserService currentUser,
            ILogger <CarAdsController> logger)
        {
            this.carAds        = carAds;
            this.dealers       = dealers;
            this.categories    = categories;
            this.manufacturers = manufacturers;
            this.currentUser   = currentUser;

            this.fullTextSearch = fullTextSearch;

            logger.LogError("Error!");
        }
예제 #4
0
 public BooksController(IFullTextSearch fullTextSearch)
 {
     _fullTextSearch = fullTextSearch;
 }