Created
September 21, 2011 08:25
-
-
Save smiler/1231558 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private enum CountryGroup_Balticum | |
{ | |
Estonia, | |
Latvia, | |
Lithuania | |
} | |
public static List<int> getCountryIDsForBaltStates(ListItemCollection countries) | |
{ | |
List<int> countryIDs = new List<int>(); | |
foreach (ListItem li in countries) | |
{ | |
if (new List<string>(typeof(CountryGroup_Balticum).GetEnumNames()).Contains(li.Text)) | |
{ | |
countryIDs.Add(Convert.ToInt32(li.Value)); | |
} | |
} | |
return countryIDs; | |
} | |
public static ListItem[] getGroupedCountries(ListItemCollection countries) | |
{ | |
if (CountryGroupHandler.listCountryGroupsCount() == 0) | |
{ | |
//List<CountryGroup> listaLandsgrupper = new List<CountryGroup>(); | |
foreach (ListItem country in countries) | |
{ | |
if (!CountryGroupHandler.isCountryInList(country.Text)) | |
{ | |
if (!new List<string>(typeof(CountryGroup_Balticum).GetEnumNames()).Contains(country.Text)) | |
{ | |
CountryGroupHandler.addCountryGroup(new CountryGroup(country.Text, new List<int>() { Convert.ToInt32(country.Value) }, Convert.ToInt32(country.Value))); | |
} | |
else //Är ett baltiskt land | |
{ | |
if (!CountryGroupHandler.isCountryInList(CountryGroupHandler.nameBalticStates)) | |
{ | |
//Lägg till baltikum. Selection ID = Estland (2) | |
CountryGroupHandler.addCountryGroup(new CountryGroup(CountryGroupHandler.nameBalticStates, getCountryIDsForBaltStates(countries), 2)); | |
} | |
} | |
} | |
} | |
} | |
//ListItemCollection licCountries = new ListItemCollection(); | |
ListItem[] liCountries = new ListItem[CountryGroupHandler.listCountryGroupsCount()]; | |
for (int i = 0; i < CountryGroupHandler.listCountryGroupsCount(); i++) | |
{ | |
liCountries[i] = new ListItem(CountryGroupHandler.getCountryGroup(i).Name, CountryGroupHandler.getCountryGroup(i).SelectionID.ToString()); | |
} | |
return liCountries ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment