private DistrictWard ContainDistrictWard(string address) { var districtWard = new DistrictWard(); foreach (var key in prepareData.DicWardFullName.Keys) { if (address.ToLower().Contains(key.ToLower())) { districtWard.Ward = prepareData.DicWardFullName[key]; } } foreach (var key in prepareData.DicDistrictFullName.Keys) { if (address.ToLower().Contains(key.ToLower())) { districtWard.District = prepareData.DicDistrictFullName[key]; } } return(districtWard); }
public List <DistrictWard> AddDistrictWard() { var listDistrictWard = new List <DistrictWard>(); var data = ConfigurationManager.AppSettings.Get("DistrictWard"); var listData = data.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in listData) { var record = item.Split(';'); if (record.Length <= 1) { continue; } var districtWard = new DistrictWard { Id = Convert.ToInt32(record[0].TrimStart().TrimEnd()), District = record[1].ToString(), Ward = record[2].ToString() }; listDistrictWard.Add(districtWard); } return(listDistrictWard); }