public async Task <JsonResult> GetAllAreas(string cityName) { try { using (var client = new RegionClient()) { var regions = await client.GetRegionByRegionNameAsync(cityName); regions.ThrowIfException(true); if (regions.Result.ChildRegions.FirstOrDefault().IsBelongMunicipality) { return(Json(regions.Result.ChildRegions.Select(s => new { name = s.DistrictName }).ToArray())); } else { return(Json(regions.Result.ChildRegions.Select(s => new { name = s.DistrictName }).ToArray())); } } } catch (Exception ex) { throw ex; } return(Json(null)); }