Пример #1
0
        public IEnumerable <T> GetAll <T>(SearchFiltersDTO searchFiltersDTO)
        {
            if (searchFiltersDTO == null)
            {
                return(new List <T>());
            }

            return(this.autopartRepository.AllAsNoTracking()
                   .Where(x => x.ConditionId == searchFiltersDTO.ConditionId &&
                          x.CategoryId == searchFiltersDTO.CategoryId &&
                          x.Car.ModelId == searchFiltersDTO.ModelId &&
                          x.Car.CarTypeId == searchFiltersDTO.CarTypeId &&
                          (searchFiltersDTO.CarMakeYear == null || x.Car.MakeYear == searchFiltersDTO.CarMakeYear) &&
                          (searchFiltersDTO.MaxPrice == null || x.Price <= searchFiltersDTO.MaxPrice))
                   .To <T>()
                   .ToList());
        }
Пример #2
0
        public IActionResult Result(SearchFiltersInputModel searchFilters)
        {
            var searchFiltersDTO = new SearchFiltersDTO
            {
                MaxPrice          = searchFilters.MaxPrice,
                ConditionId       = searchFilters.ConditionId,
                CategoryId        = searchFilters.CategoryId,
                CarManufacturerId = searchFilters.CarManufacturerId,
                ModelId           = searchFilters.ModelId,
                CarTypeId         = searchFilters.CarTypeId,
                CarMakeYear       = searchFilters.CarMakeYear,
            };

            var viewModel = this.autopartsService.GetAll <AutopartsListItemViewModel>(searchFiltersDTO);

            return(this.View(viewModel));
        }