public JsonResult LoadRegionByCity(string cityId) { if (!string.IsNullOrWhiteSpace(cityId)) { ICityRepository cityRepository = new CityRepository(_connectionString); var cityApp = new CityApplication(cityRepository); var regionList = cityApp.GetAll(); regionList = regionList.Where(c => c.Id == cityId.ToInt32()); var regionData = regionList.Select(r => new SelectListItem() { Text = r.Region.Name, Value = r.Region.Id.ToString(), }); return(Json(regionData, JsonRequestBehavior.AllowGet)); } else { IRegionRepository regionRepository = new RegionRepository(_connectionString); var regionApp = new RegionApplication(regionRepository); var regionData = regionApp.GetAll().Select(g => new SelectListItem() { Text = g.Name, Value = g.Id.ToString() }).ToList(); return(Json(regionData, JsonRequestBehavior.AllowGet)); } }
public void LoadDropDownFiltersBag() { IGenderRepository genderRepository = new GenderRepository(_connectionString); var genderApp = new GenderApplication(genderRepository); ViewBag.Genders = genderApp.GetAll().Select(g => new SelectListItem() { Text = g.Name, Value = g.Id.ToString() }).ToList(); ICityRepository cityRepository = new CityRepository(_connectionString); var cityApp = new CityApplication(cityRepository); ViewBag.Cities = cityApp.GetAll().Select(g => new SelectListItem() { Text = g.Name, Value = g.Id.ToString() }).ToList(); IRegionRepository regionRepository = new RegionRepository(_connectionString); var regionApp = new RegionApplication(regionRepository); ViewBag.Regions = regionApp.GetAll().Select(g => new SelectListItem() { Text = g.Name, Value = g.Id.ToString() }).ToList(); IClassificationRepository classificationRepository = new ClassificationRepository(_connectionString); var classificationApp = new ClassificationApplication(classificationRepository); ViewBag.Classifications = classificationApp.GetAll().Select(g => new SelectListItem() { Text = g.Name, Value = g.Id.ToString() }).ToList(); IUserSysRepository userRepository = new UserSysRepository(_connectionString); var userApp = new UserApplication(userRepository); ViewBag.Sellers = userApp.GetAll().Select(g => new SelectListItem() { Text = g.Login, Value = g.Id.ToString() }).ToList(); }