Exemple #1
0
        public async Task <IActionResult> List(SearchingOptions input, ChekedAdditionsList additionsList)
        {
            var model = new CarsListViewModel()
            {
                Cars = await this.carsService.GetAllBySearchOptions <SemiDetailedCarViewModel>(input, additionsList.Additions),
            };

            return(this.View(model));
        }
Exemple #2
0
        public async Task <IEnumerable <T> > GetAllBySearchOptions <T>(SearchingOptions model, IEnumerable <int> additions)
        {
            var query = this.carsRepository.All().AsQueryable();

            if (model.MakeId != null)
            {
                query = query
                        .Where(x => x.MakeId == model.MakeId);
            }

            if (model.ModelId != null)
            {
                query = query
                        .Where(x => x.ModelId == model.ModelId);
            }
            if (model.ColourId != null)
            {
                query = query
                        .Where(x => x.ColorId == model.ColourId);
            }

            if (model.RegionId != null)
            {
                query = query
                        .Where(x => x.RegionId == model.RegionId);
            }

            if (model.FuelId != null)
            {
                query = query
                        .Where(x => x.FuelId == model.FuelId);
            }

            if (model.GearBoxId != null)
            {
                query = query
                        .Where(x => x.GearBoxId == model.GearBoxId);
            }

            if (additions != null)
            {
                foreach (var aditionId in additions)
                {
                    query = query.Where(x => x.Additions.Any(i => i.AdditionId == aditionId));
                }
            }

            return(query.To <T>().ToList());
        }
Exemple #3
0
        public override void Execute(IDictionary <string, object> input)
        {
            var folder = input.Get <string>(FOLDER);
            var search = input.Get <string>(SEARCH);

            var indexer = _indexerFactory.GetInstance(IndexerType.Lucene);
            var options = new SearchingOptions
            {
                DataDir    = folder,
                SearchTerm = search,
                DocCount   = 20
            };
            var result = indexer.Search(options);

            foreach (var item in result)
            {
                _console.WriteLine("{0}\t{1} ({2})", item.Score, item.Path, item.Modified);
            }
        }