Beispiel #1
0
        public static List <SelectListItem> GetSubDistrict(int?defaultValue, int?provinceID, int?districtid)
        {
            List <SelectListItem> list = new List <SelectListItem>();

            var data = new AddressRepository().GetSubDistrict();

            if (provinceID.HasValue)
            {
                data = data.Where(m => m.ProvinceID == provinceID).ToList();
            }

            if (districtid.HasValue)
            {
                data = data.Where(m => m.DistrictID == districtid).ToList();
            }

            foreach (var item in data)
            {
                SelectListItem select = new SelectListItem();
                select.Value    = item.SubDistrictID.ToString();
                select.Text     = item.SubDistrictName;
                select.Selected = defaultValue.HasValue ? (item.SubDistrictID == defaultValue ? true : false) : false;
                list.Add(select);
            }
            return(list);
        }
Beispiel #2
0
        public static List <SelectListItem> GetCountry(int?defaultValue)
        {
            List <SelectListItem> list = new List <SelectListItem>();

            var data = new AddressRepository().GetCountry();

            foreach (var item in data)
            {
                SelectListItem select = new SelectListItem();
                select.Value    = item.CountryID.ToString();
                select.Text     = item.CountryName;
                select.Selected = defaultValue.HasValue ? (item.CountryID == defaultValue ? true : false) : false;
                list.Add(select);
            }
            return(list);
        }