I am working on MVC project and have a dropdown to fill with Country Name. But I want to block some country names so that they will not reflect in that dropdown. My current code is mentioned below. What should I add in my code if I do not want to show 'Liberia' in that dropdown?
I am posting the code in which my function call is running in Visual Studio
private static void FillCombos(GuestInformationPresenter model)
{
FillCountryLists(model);
}
/// <summary>
/// Function to fill countries in combos.
/// </summary>
/// <param name="model">GuestInformationPresenter type of object</param>
private static void FillCountryLists(GuestInformationPresenter model)
{
//I want to add some Linq code here to Block some countries.
model.FillCountryLists(ReservationService.RetrieveCountries());
}
public static KeyValuePair<string, string>[] RetrieveCountries()
{
var countries = from LookupData.CountryRow countryRow in LookupManagerCache.Retrieve().CountryRows
orderby countryRow.Name
select new KeyValuePair<string, string>(DataField.RetrieveValue(() => countryRow.Code), DataField.RetrieveValue(() => countryRow.Name));
return countries.ToArray();
}
/// <summary>
/// Function to retrieve collection of Countries.
/// </summary>
/// <returns>collection of countries</returns>
public static KeyValuePair<string, string>[] RetrieveCountries()
{
return LookupManager.RetrieveCountries();
}
public static Dictionary<string, string> RetrieveCountries()
{
KeyValuePair<string, string>[] countries = CruiseLookup.RetrieveCountries();
return countries.ToDictionary<KeyValuePair<string, string>, string, string>(pair => pair.Key, pair => pair.Value);
}
// GuestInformationPresenter
public void FillCountryLists(Dictionary<string, string> countryList)
{
this.CountryList = countryList;
}