private AdSearchParameters CreateSearchParameters(AdvancedAdSearchModel searchQuery) { AdSearchParameters parameters = new AdSearchParameters(); if (!String.IsNullOrEmpty(searchQuery.SearchString)) { parameters.AndSearchStrings = searchQuery.SearchString.Trim().Split(' '); } parameters.CategoryIds = GetCategoryIdsFromQuery(searchQuery.CategorySelectedId); parameters.CityId = searchQuery.CitySelectedId; parameters.MinPrice = searchQuery.MinPrice; parameters.MaxPrice = searchQuery.MaxPrice; // -- Vehicles specific properties -- // if (searchQuery.AgeBracketSelectedId.HasValue) { parameters.MaxYear = _referenceServices.GetAllAgeBrackets()[searchQuery.AgeBracketSelectedId.Value].LowValue; parameters.MaxYear = _helperService.GetCurrentDateTime().Year - parameters.MaxYear; parameters.MinYear = _referenceServices.GetAllAgeBrackets()[searchQuery.AgeBracketSelectedId.Value].HighValue; parameters.MinYear = _helperService.GetCurrentDateTime().Year - parameters.MinYear; } if (searchQuery.KmBracketSelectedId.HasValue) { parameters.MinKm = _referenceServices.GetAllKmBrackets()[searchQuery.KmBracketSelectedId.Value].LowValue; parameters.MaxKm = _referenceServices.GetAllKmBrackets()[searchQuery.KmBracketSelectedId.Value].HighValue; } if (searchQuery.EngineSizeBracketSelectedId.HasValue) { parameters.MinEngineSize = _referenceServices.GetAllEngineSizeBrackets()[searchQuery.EngineSizeBracketSelectedId.Value].LowValue; parameters.MaxEngineSize = _referenceServices.GetAllEngineSizeBrackets()[searchQuery.EngineSizeBracketSelectedId.Value].HighValue; } parameters.BrandId = searchQuery.BrandSelectedId; parameters.FueldId = searchQuery.FuelSelectedId; parameters.IsAuto = searchQuery.IsAutomatic; //-- Real Estate specific properties --// parameters.RealEstateTypeId = searchQuery.SelectedRealEstateTypeId; parameters.DistrictId = searchQuery.SelectedDistrictId; parameters.IsFurnished = searchQuery.IsFurnished; if (searchQuery.NbRoomsBracketSelectedId.HasValue) { parameters.MinNbRooms = _referenceServices.GetAllRealEstateNbRoomsBrackets()[searchQuery.NbRoomsBracketSelectedId.Value].LowValue; parameters.MaxNbRooms = _referenceServices.GetAllRealEstateNbRoomsBrackets()[searchQuery.NbRoomsBracketSelectedId.Value].HighValue; } if (searchQuery.SurfaceAreaBracketSelectedId.HasValue) { parameters.MinSurfaceArea = _referenceServices.GetAllSurfaceAreaBrackets()[searchQuery.SurfaceAreaBracketSelectedId.Value].LowValue; parameters.MaxSurfaceArea = _referenceServices.GetAllSurfaceAreaBrackets()[searchQuery.SurfaceAreaBracketSelectedId.Value].HighValue; } //-- Water sport specific properties --// parameters.MotorBoatTypeId = searchQuery.SelectedMotorBoatTypeId; parameters.MotorEngineTypeId = searchQuery.SelectedMotorTypeId; parameters.SailingBoatTypeId = searchQuery.SelectedSailingBoatTypeId; parameters.HullTypeId = searchQuery.SelectedHullTypeId; parameters.WaterTypeId = searchQuery.SelectedWaterTypeId; parameters.MinLength = searchQuery.MinLength; parameters.MaxLength = searchQuery.MaxLength; parameters.MinHp = searchQuery.MinHp; parameters.MaxHp = searchQuery.MaxHp; return(parameters); }
public void FillViewLists(Category category) { if (category == null) { return; } switch (category.Type) { case AdTypeEnum.CarAd: ViewBag.KmBrackets = _referenceServices.GetAllKmBrackets().Select(x => new SelectListItem { Text = x.Value.Label, Value = x.Key.ToString() }); ViewBag.AgeBrackets = _referenceServices.GetAllAgeBrackets().Select(x => new SelectListItem { Text = x.Value.Label, Value = x.Key.ToString() }); ViewBag.Brands = _referenceServices.GetAllCarBrands().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.Fuels = _referenceServices.GetAllCarFuels().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.MotoAd: ViewBag.Brands = _referenceServices.GetAllMotoBrands().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.KmBrackets = _referenceServices.GetAllKmBrackets().Select(x => new SelectListItem { Text = x.Value.Label, Value = x.Key.ToString() }); ViewBag.AgeBrackets = _referenceServices.GetAllAgeBrackets().Select(x => new SelectListItem { Text = x.Value.Label, Value = x.Key.ToString() }); ViewBag.EngineSizeBrackets = _referenceServices.GetAllEngineSizeBrackets().Select(x => new SelectListItem { Text = x.Value.Label, Value = x.Key.ToString() }); break; case AdTypeEnum.OtherVehiculeAd: ViewBag.KmBrackets = _referenceServices.GetAllKmBrackets().Select(x => new SelectListItem { Text = x.Value.Label, Value = x.Key.ToString() }); ViewBag.AgeBrackets = _referenceServices.GetAllAgeBrackets().Select(x => new SelectListItem { Text = x.Value.Label, Value = x.Key.ToString() }); ViewBag.Fuels = _referenceServices.GetAllCarFuels().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.VehiculeAd: ViewBag.AgeBrackets = _referenceServices.GetAllAgeBrackets().Select(x => new SelectListItem { Text = x.Value.Label, Value = x.Key.ToString() }); ViewBag.KmBrackets = _referenceServices.GetAllKmBrackets().Select(x => new SelectListItem { Text = x.Value.Label, Value = x.Key.ToString() }); break; case AdTypeEnum.RealEstateAd: ViewBag.Rooms = _referenceServices.GetAllRealEstateNbRoomsBrackets().Select(x => new SelectListItem { Text = x.Value.Label, Value = x.Key.ToString() }).ToList(); ViewBag.SurfaceAreas = _referenceServices.GetAllSurfaceAreaBrackets().Select(x => new SelectListItem { Text = x.Value.Label, Value = x.Key.ToString() }).ToList(); ViewBag.Types = _referenceServices.GetAllRealEstateTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.Districts = _locationServices.GetAllDistricts().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.FurnishedList = new List <SelectListItem>() { new SelectListItem { Text = "Meublé", Value = "true" }, new SelectListItem { Text = "Non meublé", Value = "false" } }; break; case AdTypeEnum.MotorBoatAd: ViewBag.AgeBrackets = _referenceServices.GetAllAgeBrackets().Select(x => new SelectListItem { Text = x.Value.Label, Value = x.Key.ToString() }); ViewBag.Types = _referenceServices.GetAllMotorBoatTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.MotorTypes = _referenceServices.GetAllMotorBoatEngineTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.SailingBoatAd: ViewBag.AgeBrackets = _referenceServices.GetAllAgeBrackets().Select(x => new SelectListItem { Text = x.Value.Label, Value = x.Key.ToString() }); ViewBag.Types = _referenceServices.GetAllSailingBoatTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); ViewBag.HullTypes = _referenceServices.GetAllSailingBoatHullTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.MotorBoatEngineAd: ViewBag.AgeBrackets = _referenceServices.GetAllAgeBrackets().Select(x => new SelectListItem { Text = x.Value.Label, Value = x.Key.ToString() }); ViewBag.Types = _referenceServices.GetAllMotorBoatEngineTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; case AdTypeEnum.WaterSportAd: ViewBag.Types = _referenceServices.GetAllWaterSportTypes().Select(x => new SelectListItem { Text = x.Label, Value = x.Id.ToString() }).ToList(); break; } }