public void SortList(CountryFields type, bool reverseSort) { switch (type) { case CountryFields.Name: CountryCompareByName compareByName = new CountryCompareByName(); selectedCountriesList.Sort(compareByName); break; case CountryFields.Area: CountryCompareByArea compareByArea = new CountryCompareByArea(); selectedCountriesList.Sort(compareByArea); break; case CountryFields.Gdp: CountryCompareByGdp compareByGdp = new CountryCompareByGdp(); selectedCountriesList.Sort(compareByGdp); break; case CountryFields.Population: CountryCompareByPopulation compareByPopulation = new CountryCompareByPopulation(); selectedCountriesList.Sort(compareByPopulation); break; } if (reverseSort) { selectedCountriesList.Reverse(); } InitializeDisplay(selectedCountriesList); }
/// <summary> /// Gets the countries core. /// </summary> /// <param name="configFilter">The config filter.</param> /// <param name="additionalFilter">The additional filter.</param> /// <param name="sortBy">The sort by.</param> /// <returns></returns> private static IList <Country> GetCountriesCore( string configFilter, string additionalFilter, CountryFields sortBy) { var result = new List <Country>(); using (var cmd = new SqlCommand()) { var filter = BuildCountriesFilter(configFilter, additionalFilter); cmd.CommandText = filter.Equals(string.Empty) ? "rb_GetCountries" : "rb_GetCountriesFiltered"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = ConnectionString; if (!filter.Equals(string.Empty)) { cmd.Parameters.Add("@Filter", SqlDbType.NVarChar, 10000).Value = filter; } cmd.Parameters.Add("@SortBy", SqlDbType.Int).Value = (int)sortBy; SqlDataReader reader = null; try { cmd.Connection.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { result.Add(new Country(reader.GetString(0), reader.GetString(1), reader.GetString(2))); } } finally { if (reader != null) { reader.Close(); } cmd.Connection.Close(); } } if (sortBy == CountryFields.Name) { result.Sort(new CountryNameComparer()); } return(result); }
/// <summary> /// The get countries. /// </summary> /// <param name="filter"> /// The filter. /// </param> /// <param name="sortBy"> /// The sort by. /// </param> /// <returns> /// </returns> public abstract IList <Country> GetCountries(string filter, CountryFields sortBy);
/// <summary> /// The get countries. /// </summary> /// <param name="sortBy"> /// The sort by. /// </param> /// <returns> /// </returns> public abstract IList <Country> GetCountries(CountryFields sortBy);
/// <summary> /// Gets the countries core. /// </summary> /// <param name="configFilter">The config filter.</param> /// <param name="additionalFilter">The additional filter.</param> /// <param name="sortBy">The sort by.</param> /// <returns></returns> private static IList<Country> GetCountriesCore( string configFilter, string additionalFilter, CountryFields sortBy) { var result = new List<Country>(); using (var cmd = new SqlCommand()) { var filter = BuildCountriesFilter(configFilter, additionalFilter); cmd.CommandText = filter.Equals(string.Empty) ? "rb_GetCountries" : "rb_GetCountriesFiltered"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = ConnectionString; if (!filter.Equals(string.Empty)) { cmd.Parameters.Add("@Filter", SqlDbType.NVarChar, 10000).Value = filter; } cmd.Parameters.Add("@SortBy", SqlDbType.Int).Value = (int)sortBy; SqlDataReader reader = null; try { cmd.Connection.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { result.Add(new Country(reader.GetString(0), reader.GetString(1), reader.GetString(2))); } } finally { if (reader != null) { reader.Close(); } cmd.Connection.Close(); } } if (sortBy == CountryFields.Name) { result.Sort(new CountryNameComparer()); } return result; }
/// <summary> /// The get countries. /// </summary> /// <param name="filter"> /// The filter. /// </param> /// <param name="sortBy"> /// The sort BY. /// </param> public override IList<Country> GetCountries(string filter, CountryFields sortBy) { return GetCountriesCore(this.CountriesFilter, filter, sortBy); }
/// <summary> /// The get countries. /// </summary> /// <param name="filter"> /// The filter. /// </param> /// <param name="sortBy"> /// The sort BY. /// </param> public override IList <Country> GetCountries(string filter, CountryFields sortBy) { return(GetCountriesCore(this.CountriesFilter, filter, sortBy)); }
/// <summary> /// <see cref="Rainbow.Framework.Providers.Geographic.GeographicProvider.GetCountries( CountryFields )"/> /// </summary> public override IList <Country> GetCountries(CountryFields sortBY) { return(GetCountriesCore(countriesFilter, string.Empty, sortBY)); }