/// <summary> /// 获取所有省份信息 /// </summary> /// <returns></returns> public async Task <IEnumerable <SimpleRegion> > GetAllProvince() { using (var client = new RegionClient()) { var clientResult = await client.GetAllProvinceAsync(); clientResult.ThrowIfException(true); return(clientResult.Result); } }
/// <summary> /// 获取所有省份 /// </summary> /// <returns>Json格式</returns> public async Task <ActionResult> GetAllProvince() { IEnumerable <SimpleRegion> result = null; using (var client = new RegionClient()) { var serviceResult = await client.GetAllProvinceAsync(); serviceResult.ThrowIfException(true); result = serviceResult.Result; } return(Json(new { Status = result != null, Data = result }, JsonRequestBehavior.AllowGet)); }
public async Task <JsonResult> GetAllProvinces() { try { using (var client = new RegionClient()) { var regions = await client.GetAllProvinceAsync(); regions.ThrowIfException(true); var result = regions.Result.Select(s => new { id = s.ProvinceId, name = s.ProvinceName }).ToArray(); return(Json(result)); } } catch (Exception ex) { logger.Error($"GetAllProvinces:{ex.Message}", ex); } return(Json(null)); }