public PartialViewResult ShowSearchPath()//(string PropertyType, string PropertyTypeAction, string PropertyTypeCities, string PropertyTypeCityDistrict) { string PropertyType = (Request.QueryString["PropertyType"]); string PropertyTypeAction = Request.QueryString["PropertyTypeAction"]; string PropertyTypeCities = Request.QueryString["PropertyTypeCities"]; string PropertyTypeCityDistrict = Request.QueryString["PropertyTypeCityDistrict"]; string NavigatePage = Request.QueryString["NavigatePage"]; string SortTypeDll = Request.QueryString["sortType"]; //int iPropertyType, iPropertyTypeAction, iPropertyTypeCities, iPropertyTypeCityDistrict; //iPropertyType = iPropertyTypeAction = iPropertyTypeCities = iPropertyTypeCityDistrict = -1; //int.TryParse(PropertyType, out iPropertyType); //int.TryParse(PropertyTypeAction, out iPropertyTypeAction); //int.TryParse(PropertyTypeCities, out iPropertyTypeCities); //int.TryParse(PropertyTypeCityDistrict, out iPropertyTypeCityDistrict); var model = new SearchPathModel(); //model.PropertyType = (from s in _db.PropertyTypes.AsQueryable() // where s.Id == iPropertyType // select new Pair<int, string>() { Key = iPropertyType, Value = s.PropertyTypeName }).FirstOrDefault<Pair<int, string>>(); //model.PropertyAction = (from s in _db.PropertyActions.AsQueryable() // where s.Id == iPropertyTypeAction // select new Pair<int, string>() { Key = s.Id, Value = s.PropertyActionName }).FirstOrDefault<Pair<int, string>>(); //model.City = (from s in _db.Cities.AsQueryable() // where s.Id == iPropertyTypeCities // select new Pair<int, string>() { Key = s.Id, Value = s.CityName }).FirstOrDefault<Pair<int, string>>(); //model.CityDisctict = (from s in _db.CityDistricts.AsQueryable() // where s.Id == iPropertyTypeCityDistrict // select new Pair<int, string>() { Key = s.Id, Value = s.District }).FirstOrDefault<Pair<int, string>>(); int id; #region propertyType populating int.TryParse(PropertyType, out id); if (id > 0) { var data = new PropertyTypeRoutines(this._db); model.PropertyType = data.GetById(id); model.PropertyTypes = data.GetPropertyTypes(); model.PropertyTypes = model.PropertyTypes.Where(m => m.PropertyTypeName != model.PropertyType.PropertyTypeName); model.PropertyTypes = model.PropertyTypes.Where(m => !m.PropertyTypeName.Contains("Выберите")); } #endregion #region PropertyTypeAction populating int.TryParse(PropertyTypeAction, out id); if (id > 0) { var data = new PropertyActionRoutines(this._db); model.PropertyAction = data.GetById(id); model.PropertyActions = data.GetPropertyActions(); if (model.PropertyType != null) { model.PropertyActions = model.PropertyActions.Where(m => m.PropertyType.Id == model.PropertyType.Id); } } #endregion #region PropertyTypeCities populating int.TryParse(PropertyTypeCities, out id); if (id > 0) { var data = new CityRoutines(this._db); model.City = data.GetById(id); model.Cities = data.GetCities(); model.Cities = model.Cities.Where(m => m.Id != model.City.Id); } #endregion #region PropertyTypeCityDistrict populating int.TryParse(PropertyTypeCityDistrict, out id); if (id > 0) { var data = new CityDistrictRoutines(this._db); model.CityDisctict = data.GetById(id); model.CityDiscticts = data.GetCityDiscticts(); model.CityDiscticts = model.CityDiscticts.Where(m => m.City.Id == model.CityDisctict.City.Id); model.CityDiscticts = model.CityDiscticts.Where(m => m.Id != model.CityDisctict.Id); } #endregion return PartialView("ShowSearchPath", model); }
public PartialViewResult SearchOnMap() { var data = new PropertyTypeRoutines(this._db).GetPropertyTypes().ToList<PropertyType>(); var model = new SelectList(data, "id", "PropertyTypeName", 8); return PartialView(model); }