Exemple #1
0
        /// <summary>
        /// 获取所有年检所在的市 县
        /// </summary>
        /// <returns></returns>
        public List <InspectionRegion> GetAllInspectionCityByProvinceId(int provinceId)
        {
            var result = null as List <InspectionRegion>;

            //if (Cities.Select(p => p.RegionId).Contains(provinceId))
            //{
            //    result = Cities.Where(q => q.RegionId == provinceId).ToList();
            //    return result;
            //}
            try
            {
                using (var client = new RegionClient())
                {
                    var regionresponse = client.GetRegionByRegionId(provinceId);
                    if (regionresponse != null && regionresponse.Result != null && regionresponse.Result.ChildRegions.Any())
                    {
                        result = regionresponse.Result.ChildRegions.Select(p => new InspectionRegion()
                        {
                            RegionId   = p.RegionId,
                            RegionName = p.RegionName
                        }).ToList();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("GetAllInspectionCityByProvinceId", ex);
            }
            return(result ?? new List <InspectionRegion>());
        }
 public ActionResult GetRegionByRegionId(int regionId)
 {
     using (var client = new RegionClient())
     {
         var allProvinceResult = client.GetRegionByRegionId(regionId);
         allProvinceResult.ThrowIfException(true);
         return(Json(allProvinceResult.Result, JsonRequestBehavior.AllowGet));
     }
 }
 public Service.Shop.Models.Region.Region GetRegionByRegionId(int regionId)
 {
     using (var client = new RegionClient())
     {
         var serviceResult = client.GetRegionByRegionId(regionId);
         serviceResult.ThrowIfException(true);
         return(serviceResult.Result);
     }
 }
Exemple #4
0
 public JsonResult GetAllCitys(int ProvinceId)
 {
     using (var client = new RegionClient())
     {
         var regions = client.GetRegionByRegionId(ProvinceId);
         regions.ThrowIfException(true);
         if (regions.Result.ChildRegions.FirstOrDefault().IsBelongMunicipality)
         {
             return(Json(regions.Result.ChildRegions.Select(s => new { id = s.CityId, name = s.CityName }).Distinct().ToArray()));
         }
         else
         {
             return(Json(regions.Result.ChildRegions.Select(s => new { id = s.CityId, name = s.CityName }).ToArray()));
         }
     }
 }
        /// <summary>
        /// 根据regionId获取region
        /// </summary>
        /// <param name="regionId"></param>
        /// <returns></returns>
        public static Region GetRegionByRegionId(int regionId)
        {
            Region result = null;

            try
            {
                using (var client = new RegionClient())
                {
                    var getResult = client.GetRegionByRegionId(regionId);
                    getResult.ThrowIfException(true);
                    result = getResult.Result;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            return(result);
        }
Exemple #6
0
        /// <summary>
        /// 获取所有年检所在的乡
        /// </summary>
        /// <returns></returns>
        public List <InspectionRegion> GetAllInspectionVillageByCityId(int cityId, int provinceId)
        {
            var result = null as List <InspectionRegion>;

            try
            {
                using (var client = new RegionClient())
                {
                    var regionresponse = client.GetRegionByRegionId(cityId);
                    if (regionresponse != null && regionresponse.Result != null)
                    {
                        if (Cities.Select(p => p.RegionId).Contains(provinceId))
                        {
                            result = new List <InspectionRegion>()
                            {
                                new InspectionRegion()
                                {
                                    RegionId   = regionresponse.Result.RegionId,
                                    RegionName = regionresponse.Result.RegionName
                                }
                            };
                        }
                        else if (regionresponse.Result.ChildRegions.Any())
                        {
                            result = regionresponse.Result.ChildRegions.Select(p => new InspectionRegion()
                            {
                                RegionId   = p.RegionId,
                                RegionName = p.RegionName
                            }).ToList();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("GetAllInspectionVillageByCityId", ex);
            }
            return(result ?? new List <InspectionRegion>());
        }