public List<CountryLanguageDto> GetCoutryLanguage(int? localizeId, string country, string language)
        {
            List<CountryLanguageDto> retval = null;
            DbCommand sp = null;
            DbConnection connection = null;
            IDataReader reader = null;
            try
            {
                connection = _dbLayer.GetConnection();
                sp = connection.CreateCommand();

                sp.CommandText = "select_country_language";
                sp.CommandType = CommandType.StoredProcedure;
                if (localizeId.HasValue)
                    _dbLayer.AddParameter(sp, "@localization_id", ParameterDirection.Input, DbType.Int32, localizeId);
                if (country != String.Empty)
                    _dbLayer.AddParameter(sp, "@country", ParameterDirection.Input, DbType.String, country);
                if (language != String.Empty)
                    _dbLayer.AddParameter(sp, "@language", ParameterDirection.Input, DbType.String, language);
                _dbLayer.AddReturnParameter(sp);
                reader = sp.ExecuteReader();
                retval = new List<CountryLanguageDto>();
                if (reader.Read())
                {
                    bool alreadyRead = false;
                    do
                    {
                        int localizationId = reader.GetInt32(0);
                        string _country = reader.GetString(1);
                        string _language = reader.GetString(2);
                        CountryLanguageDto i = new CountryLanguageDto(localizationId, _country, _language);
                        retval.Add(i);
                        alreadyRead = reader.Read();
                    }
                    while (alreadyRead);
                }
                else
                {
                    int err = _dbLayer.GetReturnValue(sp);
                    Trace.WriteLine("CountryLanguageDto.GetCountryLanguage() returned " + err);
                }
            }
            catch (DbException e)
            {
                Trace.WriteLine("CountryLanguageDto.GetCountryLanguage(): " + e.Message);
                retval = null;
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();
                if (sp != null)
                    sp.Dispose();
                if (connection != null)
                {
                    _dbLayer.ReturnConnection(connection);
                }
                else
                {
                    _dbLayer.ReturnConnection(connection, true);
                }
            }
            return retval;
        }
Beispiel #2
0
        private CountryLanguageDto ReadCountryLanguage(IDataReader reader)
        {
            int localization = reader.GetInt32(0);
            string country = reader.GetString(1);
            string language = reader.GetString(2);

            CountryLanguageDto cL = new CountryLanguageDto();
            cL.LocalizationId = localization;
            cL.LanguageFK = language;
            cL.CountryFK = country;

            return cL;
        }