public async Task <IActionResult> GetLocalitiesDropDownList(int id) { LocalitiesDropDownListViewModel localitiesModel = new LocalitiesDropDownListViewModel(); List <Locality> localities = await localityRepository.GetSomeAsync(l => l.RegionId == id); localitiesModel.Localities = localities.Select(s => new SelectListItem { Value = s.Id.ToString(), Text = s.Name }); return(PartialView(localitiesModel)); }
public async Task <ActionResult> СhooseSportClub(int id) { User user = await userManager.FindByIdAsync(id.ToString()); Locality locality = await localityRepository.GetOneAsync(user.LocalityId); if (user != null && locality != null) { SportClubViewModel model = new SportClubViewModel { Id = id, ReturnUrl = Request.Headers["Referer"].ToString() }; Region region = await regionRepository.GetOneAsync(locality.RegionId); int regionId = region.Id; int localityId = locality.Id; model.ClubRegionId = regionId; model.ClubLocalityId = localityId; var regions = await regionRepository.GetAllAsync(); var regionLocalities = await localityRepository.GetSomeAsync(l => l.RegionId == regionId); var localityClubs = await sportClubRepository.GetSomeAsync(c => c.LocalityId == localityId); model.ClubRegions = regions .Select(r => new SelectListItem { Value = r.Id.ToString(), Text = r.Name, Selected = model.ClubRegionId.Equals(regionId) }); model.ClubLocalities = regionLocalities .Select(i => new SelectListItem { Value = i.Id.ToString(), Text = i.Name, Selected = model.ClubLocalityId.Equals(localityId) }); model.Clubs = localityClubs .Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Name }); return(View(model)); } return(BadRequest()); }