Beispiel #1
0
        public static List <Cuisine> GetAll()
        {
            List <Cuisine> allTypes = new List <Cuisine> {
            };
            MySqlCnnection conn     = DB.Connection();

            conn.Open();
            MySqlCommand cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT * FROM cuisine;";
            MySqlDataeader rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                string  cuisineName        = rdr.GetString(0);
                string  cuisineDescription = rdr.GetString(1);
                int     cuisineId          = GetInt32(2);
                Cuisine newCuisine         = new Cuisine(cuisineName, cuisineDescription, cuisineId);
                allTypes.Add(newCuisine);
            }
            conn.Close();

            if (conn != null)
            {
                conn.Dispose();
            }
            return(allPlaces);
        }
        public static List <Restaurant> GetAll()
        {
            List <Restaurant> allPlaces = new List <Restaurant> {
            };
            MySqlCnnection conn         = DB.Connection();

            conn.Open();
            MySqlCommand cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT * FROM restaurant;";
            MySqlDataeader rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                string     restaurantName      = rdr.GetString(0);
                int        restaurantCuisineId = rdr.GetInt32(1);
                string     restaurantCuisine   = rdr.GetString(2);
                int        restaurantId        = GetInt32(3);
                Restaurant newRestaurant       = new Restaurant(restaurantName, restaurantCuisineId, restaurantCuisine, restaurantId);
                allPlaces.Add(newRestaurant);
            }
            conn.Close();

            if (conn != null)
            {
                conn.Dispose();
            }
            return(allPlaces);
        }