示例#1
0
        /// <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);
            }
        }
示例#2
0
        /// <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));
        }
示例#3
0
        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));
        }