예제 #1
0
        private List <RegionListItem> GetRegionDictionary()
        {
            List <RegionListItem> pItems = new List <RegionListItem>();

            Dictionary <int, string> provinces = RegionHelper.GetAllProvinces();

            RegionListItem province = null;

            foreach (var p in provinces)
            {
                province = new RegionListItem("PROVINCE", 1);

                province.Id       = p.Key;
                province.Name     = p.Value;
                province.ParentId = 0;

                Dictionary <int, string> cities = RegionHelper.GetCitys(province.Id);

                List <RegionListItem> cItems = new List <RegionListItem>();
                RegionListItem        city   = null;
                foreach (var c in cities)
                {
                    city = new RegionListItem("CITY", 2);

                    city.Id       = c.Key;
                    city.Name     = c.Value;
                    city.ParentId = province.Id;

                    Dictionary <int, string> districts = RegionHelper.GetCountys(city.Id);
                    List <RegionListItem>    dItems    = new List <RegionListItem>();
                    RegionListItem           district  = null;
                    foreach (var d in districts)
                    {
                        district = new RegionListItem("DISTRICT", 3);

                        district.Id       = d.Key;
                        district.Name     = d.Value;
                        district.ParentId = city.Id;

                        dItems.Add(district);
                    }

                    city.Children = dItems;

                    cItems.Add(city);
                }

                province.Children = cItems;

                pItems.Add(province);
            }

            return(pItems);
        }
예제 #2
0
        public RegionListItem GetRegionById(int regionId)
        {
            var regionEntity = _context.Region.Find(regionId);
            var regionDetail = new RegionListItem
            {
                RegionID         = regionEntity.RegionID,
                LocationInRegion = regionEntity.LocationInRegion,
                RegionName       = regionEntity.RegionName
            };

            return(regionDetail);
        }