示例#1
0
        /// <summary>
        /// Gets all the states
        /// </summary>
        /// <exception cref="CityManagerException">Thrown when unable to get states</exception>
        /// <returns>Returns the list of states from database</returns>
        public List <State> GetStates()
        {
            List <State> states = null;

            try
            {
                DataSet ds = cityDAO.GetStates();

                states = new List <State>();

                foreach (DataRow rw in ds.Tables[0].Rows)
                {
                    State state = new State();

                    state.StateId = Convert.ToInt32(rw["StateId"]);
                    state.Name    = rw["StateName"].ToString();

                    states.Add(state);
                }
            }
            catch (CityDAOException ex)
            {
                throw new CityManagerException("Unable to get states", ex);
            }

            return(states);
        }
示例#2
0
 /// <summary>
 /// Gets all the states
 /// </summary>
 /// <exception cref="CityManagerException">Thrown when unable to get states</exception>
 /// <returns>Returns the list of states from database</returns>
 public List <State> GetStates()
 {
     try
     {
         return(cityDAO.GetStates());
     }
     catch (CityDAOException ex)
     {
         throw new CityManagerException("Unable to get states", ex);
     }
 }
示例#3
0
        /// <summary>
        /// Gets all the states
        /// </summary>
        /// <exception cref="CityManagerException">Thrown when unable to get states</exception>
        /// <returns>Returns the list of states from database</returns>
        public List <State> GetStates()
        {
            try
            {
                DataSet ds     = cityDAO.GetStates();
                var     states = from state in ds.Tables[0].AsEnumerable().Distinct()
                                 orderby state["StateName"]
                                 select new State
                {
                    StateId = Convert.ToInt64(state["StateId"]),
                    Name    = state["StateName"].ToString()
                };

                return(states.ToList <State>());
            }
            catch (CityDAOException ex)
            {
                throw new CityManagerException("Unable to get states", ex);
            }
        }