Ejemplo n.º 1
0
        public List <Country> GetAllCountry(CountryAdvanceSearch CountryAdvanceSearch)
        {
            List <Country> CountryList = null;

            try
            {
                using (SqlConnection con = _databaseFactory.GetDBConnection())
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                        }
                        cmd.Connection  = con;
                        cmd.CommandText = "[PSA].[GetAllCountry]";
                        cmd.Parameters.Add("@SearchValue", SqlDbType.NVarChar, -1).Value = string.IsNullOrEmpty(CountryAdvanceSearch.SearchTerm) ? "" : CountryAdvanceSearch.SearchTerm;
                        cmd.Parameters.Add("@RowStart", SqlDbType.Int).Value             = CountryAdvanceSearch.DataTablePaging.Start;
                        if (CountryAdvanceSearch.DataTablePaging.Length == -1)
                        {
                            cmd.Parameters.AddWithValue("@Length", DBNull.Value);
                        }
                        else
                        {
                            cmd.Parameters.Add("@Length", SqlDbType.Int).Value = CountryAdvanceSearch.DataTablePaging.Length;
                        }
                        cmd.CommandType = CommandType.StoredProcedure;
                        using (SqlDataReader sdr = cmd.ExecuteReader())
                        {
                            if ((sdr != null) && (sdr.HasRows))
                            {
                                CountryList = new List <Country>();
                                while (sdr.Read())
                                {
                                    Country Country = new Country();
                                    {
                                        Country.Code          = (sdr["Code"].ToString() != "" ? int.Parse(sdr["Code"].ToString()) : Country.Code);
                                        Country.Description   = (sdr["Description"].ToString() != "" ? sdr["Description"].ToString() : Country.Description);
                                        Country.TotalCount    = (sdr["TotalCount"].ToString() != "" ? int.Parse(sdr["TotalCount"].ToString()) : Country.TotalCount);
                                        Country.FilteredCount = (sdr["FilteredCount"].ToString() != "" ? int.Parse(sdr["FilteredCount"].ToString()) : Country.FilteredCount);
                                    }
                                    CountryList.Add(Country);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(CountryList);
        }
Ejemplo n.º 2
0
 public List <Country> GetAllCountry(CountryAdvanceSearch countryAdvanceSearch)
 {
     return(_countryRepository.GetAllCountry(countryAdvanceSearch));
 }