Пример #1
0
        public IQueryable <Automobile> ValidateSearchProperties(MainSearchInputModel inputModel, IQueryable <Automobile> automobiles)
        {
            if (inputModel.Suspensions == null)
            {
                return(automobiles);
            }

            var suspensions = inputModel.Suspensions;

            var ElectronicSuspensionControl = suspensions.ElectronicSuspensionControl.HasValue ? suspensions.ElectronicSuspensionControl : false;
            var AdaptiveAirSuspension       = suspensions.AdaptiveAirSuspension.HasValue ? suspensions.AdaptiveAirSuspension : false;
            var LockingDifferential         = suspensions.LockingDifferential.HasValue ? suspensions.LockingDifferential : false;
            var ActiveSuspension            = suspensions.ActiveSuspension.HasValue ? suspensions.ActiveSuspension : false;

            if (ElectronicSuspensionControl == true)
            {
                automobiles = automobiles.Where(x => x.Suspensions.ElectronicSuspensionControl == true);
            }
            if (AdaptiveAirSuspension == true)
            {
                automobiles = automobiles.Where(x => x.Suspensions.AdaptiveAirSuspension == true);
            }
            if (LockingDifferential == true)
            {
                automobiles = automobiles.Where(x => x.Suspensions.LockingDifferential == true);
            }
            if (ActiveSuspension == true)
            {
                automobiles = automobiles.Where(x => x.Suspensions.ActiveSuspension == true);
            }

            return(automobiles);
        }
Пример #2
0
        public async Task <IActionResult> Results(MainSearchInputModel model, int page = 1)
        {
            var query = HttpContext.Request.QueryString.ToString();

            this.ViewData["query"] = Uri.EscapeUriString(query);

            SearchResultListingViewModel viewModel = await this.searchService.GetSearchResultsAsync(model, ItemsPerPage, (page - 1) *ItemsPerPage);

            if (viewModel == null)
            {
                return(this.View(viewModel));
            }
            int countOfAutomobiles = viewModel == null ? 0 : viewModel.SearchResults.Count();

            if (viewModel?.PagesCount == null)
            {
                viewModel.PagesCount = (int)Math.Ceiling((double)countOfAutomobiles / ItemsPerPage);
            }

            if (viewModel.PagesCount == 0)
            {
                viewModel.PagesCount = 1;
            }

            viewModel.CurrentPage = page;

            return(this.View(viewModel));
        }
Пример #3
0
        public IActionResult AdvancedSearch(MainSearchInputModel model)

        {
            if (!this.searchService.SearchModelIsNull(model))
            {
                return(this.RedirectToAction("Results", model));
            }

            return(this.View(model));
        }
        public IQueryable <Automobile> ValidateSearchProperties(MainSearchInputModel inputModel, IQueryable <Automobile> automobiles)
        {
            if (inputModel.SpecializedFeatures == null)
            {
                return(automobiles);
            }

            var specialized = inputModel.SpecializedFeatures;

            var DisabledAccessible = specialized.DisabledAccessible.HasValue ? specialized.DisabledAccessible : false;
            var Taxi      = specialized.Taxi.HasValue ? specialized.Taxi : false;
            var Ambulance = specialized.Ambulance.HasValue ? specialized.Ambulance : false;

            var Hearse  = specialized.Hearse.HasValue ? specialized.Hearse : false;
            var Learner = specialized.Learner.HasValue ? specialized.Learner : false;

            if (DisabledAccessible == true)
            {
                automobiles = automobiles.Where(x => x.SpecializedFeatures.DisabledAccessible == true);
            }
            if (Taxi == true)
            {
                automobiles = automobiles.Where(x => x.SpecializedFeatures.Taxi == true);
            }
            if (Ambulance == true)
            {
                automobiles = automobiles.Where(x => x.SpecializedFeatures.Ambulance == true);
            }
            if (Hearse == true)
            {
                automobiles = automobiles.Where(x => x.SpecializedFeatures.Hearse == true);
            }
            if (Learner == true)
            {
                automobiles = automobiles.Where(x => x.SpecializedFeatures.Learner == true);
            }

            return(automobiles);
        }
Пример #5
0
        public IQueryable <Automobile> ValidateSearchProperties(MainSearchInputModel inputModel, IQueryable <Automobile> automobiles)
        {
            if (inputModel.InteriorMaterials == null)
            {
                return(automobiles);
            }

            var interiorMaterials = inputModel.InteriorMaterials;

            var LeatherSteeringWheel = interiorMaterials.LeatherSteeringWheel.HasValue ? interiorMaterials.LeatherSteeringWheel : false;
            var LeatherSeats         = interiorMaterials.LeatherSeats.HasValue ? interiorMaterials.LeatherSeats : false;
            var ClothSeats           = interiorMaterials.ClothSeats.HasValue ? interiorMaterials.ClothSeats : false;
            var Alcantara            = interiorMaterials.Alcantara.HasValue ? interiorMaterials.Alcantara : false;
            var Velour = interiorMaterials.Velour.HasValue ? interiorMaterials.Velour : false;

            if (LeatherSteeringWheel == true)
            {
                automobiles = automobiles.Where(x => x.InteriorMaterials.LeatherSteeringWheel == true);
            }
            if (LeatherSeats == true)
            {
                automobiles = automobiles.Where(x => x.InteriorMaterials.LeatherSeats == true);
            }
            if (ClothSeats == true)
            {
                automobiles = automobiles.Where(x => x.InteriorMaterials.ClothSeats == true);
            }
            if (Alcantara == true)
            {
                automobiles = automobiles.Where(x => x.InteriorMaterials.Alcantara == true);
            }
            if (Velour == true)
            {
                automobiles = automobiles.Where(x => x.InteriorMaterials.Velour == true);
            }

            return(automobiles);
        }
        public IQueryable <Automobile> ValidateSearchProperties(MainSearchInputModel inputModel, IQueryable <Automobile> automobiles)
        {
            if (inputModel.Interiors == null)
            {
                return(automobiles);
            }

            var interiors = inputModel.Interiors;

            var Bluetooth      = interiors.Bluetooth.HasValue ? interiors.Bluetooth : false;
            var DVDPlayer      = interiors.DVDPlayer.HasValue ? interiors.DVDPlayer : false;
            var PaddleShifters = interiors.PaddleShifters.HasValue ? interiors.PaddleShifters : false;
            var USBAux         = interiors.USBAux.HasValue ? interiors.USBAux : false;
            var BoardComputer  = interiors.BoardComputer.HasValue ? interiors.BoardComputer : false;
            var PowerMirrors   = interiors.PowerMirrors.HasValue ? interiors.PowerMirrors : false;

            var PowerWindows          = interiors.PowerWindows.HasValue ? interiors.PowerWindows : false;
            var ElectronicSeatControl = interiors.ElectronicSeatControl.HasValue ? interiors.ElectronicSeatControl : false;
            var AmbientLighting       = interiors.AmbientLighting.HasValue ? interiors.AmbientLighting : false;
            var Navigation            = interiors.Navigation.HasValue ? interiors.Navigation : false;
            var HeatedSteeringWheel   = interiors.HeatedSteeringWheel.HasValue ? interiors.HeatedSteeringWheel : false;
            var Fridge = interiors.Fridge.HasValue ? interiors.Fridge : false;

            var HeatedSeats   = interiors.HeatedSeats.HasValue ? interiors.HeatedSeats : false;
            var Stereo        = interiors.Stereo.HasValue ? interiors.Stereo : false;
            var AutoPilot     = interiors.AutoPilot.HasValue ? interiors.AutoPilot : false;
            var AndroidAuto   = interiors.AndroidAuto.HasValue ? interiors.AndroidAuto : false;
            var AppleCarPlay  = interiors.AppleCarPlay.HasValue ? interiors.AppleCarPlay : false;
            var PowerSteering = interiors.PowerSteering.HasValue ? interiors.PowerSteering : false;

            var AirConditioning = interiors.AirConditioning.HasValue ? interiors.AirConditioning : false;
            var MultiFunctionalSteeringWheel = interiors.MultiFunctionalSteeringWheel.HasValue ? interiors.MultiFunctionalSteeringWheel : false;
            var HeadUpDisplay    = interiors.HeadUpDisplay.HasValue ? interiors.HeadUpDisplay : false;
            var SmokerPackage    = interiors.SmokerPackage.HasValue ? interiors.SmokerPackage : false;
            var ArmRest          = interiors.ArmRest.HasValue ? interiors.ArmRest : false;
            var HeatedWindshield = interiors.HeatedWindshield.HasValue ? interiors.HeatedWindshield : false;

            var StartStopSystem = interiors.StartStopSystem.HasValue ? interiors.StartStopSystem : false;
            var RainSensor      = interiors.RainSensor.HasValue ? interiors.RainSensor : false;
            var CentralLocking  = interiors.CentralLocking.HasValue ? interiors.CentralLocking : false;
            var MassageSeats    = interiors.MassageSeats.HasValue ? interiors.MassageSeats : false;


            if (Bluetooth == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.Bluetooth == true);
            }

            if (DVDPlayer == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.DVDPlayer == true);
            }

            if (PaddleShifters == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.PaddleShifters == true);
            }

            if (USBAux == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.USBAux == true);
            }

            if (BoardComputer == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.BoardComputer == true);
            }
            if (PowerMirrors == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.PowerMirrors == true);
            }

            if (PowerWindows == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.PowerWindows == true);
            }

            if (ElectronicSeatControl == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.ElectronicSeatControl == true);
            }

            if (AmbientLighting == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.AmbientLighting == true);
            }

            if (Navigation == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.Navigation == true);
            }
            if (HeatedSteeringWheel == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.HeatedSteeringWheel == true);
            }

            if (Fridge == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.Fridge == true);
            }

            if (HeatedSeats == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.HeatedSeats == true);
            }

            if (Stereo == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.Stereo == true);
            }

            if (AutoPilot == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.AutoPilot == true);
            }
            if (AndroidAuto == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.AndroidAuto == true);
            }

            if (AppleCarPlay == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.AppleCarPlay == true);
            }

            if (PowerSteering == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.PowerSteering == true);
            }

            if (AirConditioning == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.AirConditioning == true);
            }

            if (MultiFunctionalSteeringWheel == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.MultiFunctionalSteeringWheel == true);
            }
            if (HeadUpDisplay == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.HeadUpDisplay == true);
            }

            if (SmokerPackage == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.SmokerPackage == true);
            }

            if (ArmRest == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.ArmRest == true);
            }

            if (HeatedWindshield == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.HeatedWindshield == true);
            }

            if (StartStopSystem == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.StartStopSystem == true);
            }
            if (RainSensor == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.RainSensor == true);
            }

            if (CentralLocking == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.CentralLocking == true);
            }

            if (MassageSeats == true)
            {
                automobiles = automobiles.Where(x => x.Interiors.MassageSeats == true);
            }

            return(automobiles);
        }
Пример #7
0
        public IQueryable <Automobile> ValidateSearchProperties(MainSearchInputModel inputModel, IQueryable <Automobile> automobiles)
        {
            if (inputModel.Safety == null)
            {
                return(automobiles);
            }

            var safety = inputModel.Safety;

            var GPS = safety.GPS.HasValue ? safety.GPS : false;
            var StabilityControl     = safety.StabilityControl.HasValue ? safety.StabilityControl : false;
            var TractionControl      = safety.TractionControl.HasValue ? safety.TractionControl : false;
            var AdaptiveHeadlights   = safety.AdaptiveHeadlights.HasValue ? safety.AdaptiveHeadlights : false;
            var AutomaticBrakeSystem = safety.AutomaticBrakeSystem.HasValue ? safety.AutomaticBrakeSystem : false;
            var FrontAirbags         = safety.FrontAirbags.HasValue ? safety.FrontAirbags : false;
            var RearAirbags          = safety.RearAirbags.HasValue ? safety.RearAirbags : false;

            var SideAirbags                  = safety.SideAirbags.HasValue ? safety.SideAirbags : false;
            var FourWheelSteering            = safety.FourWheelSteering.HasValue ? safety.FourWheelSteering : false;
            var ElectronicStabilityProgram   = safety.ElectronicStabilityProgram.HasValue ? safety.ElectronicStabilityProgram : false;
            var TirePressureMonitoringSystem = safety.TirePressureMonitoringSystem.HasValue ? safety.TirePressureMonitoringSystem : false;
            var RearParkingSensor            = safety.RearParkingSensor.HasValue ? safety.RearParkingSensor : false;
            var FrontParkingSensor           = safety.FrontParkingSensor.HasValue ? safety.FrontParkingSensor : false;
            var ISOFIX = safety.ISOFIX.HasValue ? safety.ISOFIX : false;

            var ForwardCollisionWarning   = safety.ForwardCollisionWarning.HasValue ? safety.ForwardCollisionWarning : false;
            var AutomaticEmergencyBraking = safety.AutomaticEmergencyBraking.HasValue ? safety.AutomaticEmergencyBraking : false;
            var PedestrianDetection       = safety.PedestrianDetection.HasValue ? safety.PedestrianDetection : false;
            var BlindSpotMonitoring       = safety.BlindSpotMonitoring.HasValue ? safety.BlindSpotMonitoring : false;
            var LaneKeepingAssistance     = safety.LaneKeepingAssistance.HasValue ? safety.LaneKeepingAssistance : false;
            var AdaptiveCruiseControl     = safety.AdaptiveCruiseControl.HasValue ? safety.AdaptiveCruiseControl : false;
            var LaneCenteringAssist       = safety.LaneCenteringAssist.HasValue ? safety.LaneCenteringAssist : false;

            var HillDescendAssist   = safety.HillDescendAssist.HasValue ? safety.HillDescendAssist : false;
            var DistTronic          = safety.DistTronic.HasValue ? safety.DistTronic : false;
            var FourWheelDrive      = safety.FourWheelDrive.HasValue ? safety.FourWheelDrive : false;
            var AlarmSystem         = safety.AlarmSystem.HasValue ? safety.AlarmSystem : false;
            var EmergencyCallSystem = safety.EmergencyCallSystem.HasValue ? safety.EmergencyCallSystem : false;

            if (GPS == true)
            {
                automobiles = automobiles.Where(x => x.Safety.GPS == true);
            }
            if (StabilityControl == true)
            {
                automobiles = automobiles.Where(x => x.Safety.StabilityControl == true);
            }
            if (TractionControl == true)
            {
                automobiles = automobiles.Where(x => x.Safety.TractionControl == true);
            }
            if (AdaptiveHeadlights == true)
            {
                automobiles = automobiles.Where(x => x.Safety.AdaptiveHeadlights == true);
            }
            if (AutomaticBrakeSystem == true)
            {
                automobiles = automobiles.Where(x => x.Safety.AutomaticBrakeSystem == true);
            }
            if (FrontAirbags == true)
            {
                automobiles = automobiles.Where(x => x.Safety.FrontAirbags == true);
            }
            if (RearAirbags == true)
            {
                automobiles = automobiles.Where(x => x.Safety.RearAirbags == true);
            }
            if (SideAirbags == true)
            {
                automobiles = automobiles.Where(x => x.Safety.SideAirbags == true);
            }
            if (FourWheelSteering == true)
            {
                automobiles = automobiles.Where(x => x.Safety.FourWheelSteering == true);
            }
            if (ElectronicStabilityProgram == true)
            {
                automobiles = automobiles.Where(x => x.Safety.ElectronicStabilityProgram == true);
            }
            if (TirePressureMonitoringSystem == true)
            {
                automobiles = automobiles.Where(x => x.Safety.TirePressureMonitoringSystem == true);
            }
            if (RearParkingSensor == true)
            {
                automobiles = automobiles.Where(x => x.Safety.RearParkingSensor == true);
            }
            if (FrontParkingSensor == true)
            {
                automobiles = automobiles.Where(x => x.Safety.FrontParkingSensor == true);
            }
            if (ISOFIX == true)
            {
                automobiles = automobiles.Where(x => x.Safety.ISOFIX == true);
            }
            if (ForwardCollisionWarning == true)
            {
                automobiles = automobiles.Where(x => x.Safety.ForwardCollisionWarning == true);
            }
            if (AutomaticEmergencyBraking == true)
            {
                automobiles = automobiles.Where(x => x.Safety.AutomaticEmergencyBraking == true);
            }
            if (PedestrianDetection == true)
            {
                automobiles = automobiles.Where(x => x.Safety.PedestrianDetection == true);
            }
            if (BlindSpotMonitoring == true)
            {
                automobiles = automobiles.Where(x => x.Safety.BlindSpotMonitoring == true);
            }
            if (LaneKeepingAssistance == true)
            {
                automobiles = automobiles.Where(x => x.Safety.LaneKeepingAssistance == true);
            }
            if (AdaptiveCruiseControl == true)
            {
                automobiles = automobiles.Where(x => x.Safety.AdaptiveCruiseControl == true);
            }
            if (LaneCenteringAssist == true)
            {
                automobiles = automobiles.Where(x => x.Safety.LaneCenteringAssist == true);
            }
            if (HillDescendAssist == true)
            {
                automobiles = automobiles.Where(x => x.Safety.HillDescendAssist == true);
            }
            if (DistTronic == true)
            {
                automobiles = automobiles.Where(x => x.Safety.DistTronic == true);
            }
            if (FourWheelDrive == true)
            {
                automobiles = automobiles.Where(x => x.Safety.FourWheelDrive == true);
            }
            if (AlarmSystem == true)
            {
                automobiles = automobiles.Where(x => x.Safety.AlarmSystem == true);
            }
            if (EmergencyCallSystem == true)
            {
                automobiles = automobiles.Where(x => x.Safety.EmergencyCallSystem == true);
            }


            return(automobiles);
        }
        public IQueryable <Automobile> ValidateSearchProperties(MainSearchInputModel inputModel, IQueryable <Automobile> automobiles)
        {
            if (inputModel.ExtraFeatures == null)
            {
                return(automobiles);
            }

            var extraFeatures = inputModel.ExtraFeatures;

            var KeylessEntry    = extraFeatures.KeylessEntry.HasValue ? extraFeatures.KeylessEntry : false;
            var KeylessIgnition = extraFeatures.KeylessIgnition.HasValue ? extraFeatures.KeylessIgnition : false;
            var LowGear         = extraFeatures.LowGear.HasValue ? extraFeatures.LowGear : false;
            var PanoramicRoof   = extraFeatures.PanoramicRoof.HasValue ? extraFeatures.PanoramicRoof : false;
            var RoofRack        = extraFeatures.RoofRack.HasValue ? extraFeatures.RoofRack : false;

            var ElectricTailgate = extraFeatures.ElectricTailgate.HasValue ? extraFeatures.ElectricTailgate : false;
            var LongBase         = extraFeatures.LongBase.HasValue ? extraFeatures.LongBase : false;
            var ShortBase        = extraFeatures.ShortBase.HasValue ? extraFeatures.ShortBase : false;
            var Registered       = extraFeatures.Registered.HasValue ? extraFeatures.Registered : false;
            var MOT = extraFeatures.MOT.HasValue ? extraFeatures.MOT : false;

            if (KeylessEntry == true)
            {
                automobiles = automobiles.Where(x => x.ExtraFeatures.KeylessEntry == true);
            }
            if (KeylessIgnition == true)
            {
                automobiles = automobiles.Where(x => x.ExtraFeatures.KeylessIgnition == true);
            }
            if (LowGear == true)
            {
                automobiles = automobiles.Where(x => x.ExtraFeatures.LowGear == true);
            }
            if (PanoramicRoof == true)
            {
                automobiles = automobiles.Where(x => x.ExtraFeatures.PanoramicRoof == true);
            }
            if (RoofRack == true)
            {
                automobiles = automobiles.Where(x => x.ExtraFeatures.RoofRack == true);
            }
            if (ElectricTailgate == true)
            {
                automobiles = automobiles.Where(x => x.ExtraFeatures.ElectricTailgate == true);
            }
            if (LongBase == true)
            {
                automobiles = automobiles.Where(x => x.ExtraFeatures.LongBase == true);
            }
            if (ShortBase == true)
            {
                automobiles = automobiles.Where(x => x.ExtraFeatures.ShortBase == true);
            }
            if (Registered == true)
            {
                automobiles = automobiles.Where(x => x.ExtraFeatures.Registered == true);
            }
            if (MOT == true)
            {
                automobiles = automobiles.Where(x => x.ExtraFeatures.MOT == true);
            }

            return(automobiles);
        }
Пример #9
0
        public IQueryable <Automobile> ValidateSearchProperties(MainSearchInputModel inputModel, IQueryable <Automobile> automobiles)
        {
            if (inputModel.PrimaryProperties == null)
            {
                return(automobiles);
            }

            var make  = !string.IsNullOrEmpty(inputModel.PrimaryProperties.Make)? inputModel.PrimaryProperties.Make:null;
            var model = !string.IsNullOrEmpty(inputModel.PrimaryProperties.Model) ? inputModel.PrimaryProperties.Model : null;

            var yearFrom       = inputModel.PrimaryProperties.YearFrom.HasValue ? inputModel.PrimaryProperties.YearFrom : -1;
            var yearTo         = inputModel.PrimaryProperties.YearTo.HasValue ? inputModel.PrimaryProperties.YearTo : -1;
            var horsePowerFrom = inputModel.PrimaryProperties.HorsepowerFrom.HasValue ? inputModel.PrimaryProperties.HorsepowerFrom : -1;

            var priceFrom = inputModel.PrimaryProperties.PriceFrom.HasValue ? inputModel.PrimaryProperties.PriceFrom : -1;
            var priceTo   = inputModel.PrimaryProperties.PriceTo.HasValue ? inputModel.PrimaryProperties.PriceFrom : -1;
            var mileageTo = inputModel.PrimaryProperties.MileageTo.HasValue ? inputModel.PrimaryProperties.MileageTo : -1;

            var color     = inputModel.PrimaryProperties.Color.HasValue ? (int)inputModel.PrimaryProperties.Color : -1;
            var engine    = inputModel.PrimaryProperties.Engine.HasValue ? (int)inputModel.PrimaryProperties.Engine : -1;
            var gearbox   = inputModel.PrimaryProperties.GearBox.HasValue ? (int)inputModel.PrimaryProperties.GearBox : -1;
            var condition = inputModel.PrimaryProperties.Condition.HasValue ? (int)inputModel.PrimaryProperties.Condition : -1;
            var body      = inputModel.PrimaryProperties.Body.HasValue ? (int)inputModel.PrimaryProperties.Body : -1;
            var region    = inputModel.PrimaryProperties.Region.HasValue ? (int)inputModel.PrimaryProperties.Region : -1;

            if (!string.IsNullOrEmpty(make))
            {
                automobiles = automobiles.Where(x => x.Make.Name == make);
            }
            if (!string.IsNullOrEmpty(model))
            {
                automobiles = automobiles.Where(x => x.Model.Name == model);
            }

            if (yearFrom.Value >= 0)
            {
                automobiles = automobiles.Where(x => x.PrimaryProperties.Year >= yearFrom);
            }
            if (yearTo.Value >= 0)
            {
                automobiles = automobiles.Where(x => x.PrimaryProperties.Year <= yearTo);
            }
            if (horsePowerFrom.Value >= 0)
            {
                automobiles = automobiles.Where(x => x.PrimaryProperties.Horsepower >= horsePowerFrom);
            }
            if (priceFrom.Value >= 0)
            {
                automobiles = automobiles.Where(x => x.PrimaryProperties.Price >= priceFrom);
            }
            if (priceTo.Value >= 0)
            {
                automobiles = automobiles.Where(x => x.PrimaryProperties.Price <= priceTo);
            }
            if (mileageTo.Value >= 0)
            {
                automobiles = automobiles.Where(x => x.PrimaryProperties.Mileage <= mileageTo);
            }
            if (color >= 0)
            {
                automobiles = automobiles.Where(x => (int)x.PrimaryProperties.Color == color);
            }
            if (engine >= 0)
            {
                automobiles = automobiles.Where(x => (int)x.PrimaryProperties.Engine == engine);
            }
            if (gearbox >= 0)
            {
                automobiles = automobiles.Where(x => (int)x.PrimaryProperties.GearBox == gearbox);
            }
            if (condition >= 0)
            {
                automobiles = automobiles.Where(x => (int)x.PrimaryProperties.Condition == condition);
            }
            if (body >= 0)
            {
                automobiles = automobiles.Where(x => (int)x.PrimaryProperties.Body == body);
            }
            if (region >= 0)
            {
                automobiles = automobiles.Where(x => (int)x.PrimaryProperties.Region == region);
            }

            return(automobiles);
        }
        public async Task <SearchResultListingViewModel> GetSearchResultsAsync(MainSearchInputModel inputModel, int?take = null, int skip = 0)
        {
            if (this.SearchModelIsNull(inputModel.PrimaryProperties))
            {
                return(null);
            }
            if (this.SearchModelIsNull(inputModel))
            {
                return(null);
            }
            var automobiles = this.dbContext
                              .Automobiles
                              .Where(x => x.IsDeleted == false)
                              .Include(x => x.Make)
                              .Include(x => x.Model)
                              .Include(x => x.User)
                              .AsNoTracking();

            automobiles = primaryPropertiesValidator.ValidateSearchProperties(inputModel, automobiles);
            automobiles = interiorsValidator.ValidateSearchProperties(inputModel, automobiles);
            automobiles = interiorMaterialsvalidator.ValidateSearchProperties(inputModel, automobiles);
            automobiles = safetyValidator.ValidateSearchProperties(inputModel, automobiles);
            automobiles = specializedFeaturesValidator.ValidateSearchProperties(inputModel, automobiles);
            automobiles = suspensionsValidator.ValidateSearchProperties(inputModel, automobiles);
            automobiles = extraFeaturesValidator.ValidateSearchProperties(inputModel, automobiles);

            if (take.HasValue)
            {
                automobiles = automobiles
                              .OrderByDescending(x => x.CreatedOn)
                              .Skip(skip)
                              .Take(take.Value);
            }
            else
            {
                automobiles = automobiles
                              .OrderByDescending(x => x.CreatedOn)
                              .Skip(skip);
            }

            var searchResults = await automobiles
                                .Select(x => new SearchResultConciseViewModel
            {
                Id         = x.Id,
                Make       = x.Make.Name,
                Model      = x.Model.Name,
                SellerId   = x.UserId,
                SellerName = x.User.UserName,
                Title      = x.Title,
                Mileage    = x.PrimaryProperties.Mileage,
                CreatedOn  = x.CreatedOn,
                Year       = x.PrimaryProperties.Year,
                Price      = x.PrimaryProperties.Price,
                ImageUrl   = x.Images.ImageUrl1
            })
                                .ToListAsync();

            var viewModel = new SearchResultListingViewModel {
                SearchResults = searchResults
            };

            return(viewModel);
        }