Ejemplo n.º 1
0
        public List <BackgroundSoundClip> GetAllBackgroundSoundClips()
        {
            List <BackgroundSoundClip> backgroundSoundClips = new List <BackgroundSoundClip>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(@"SELECT * FROM trail_sounds", conn);

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        BackgroundSoundClip soundClip = new BackgroundSoundClip()
                        {
                            AudioId      = Convert.ToInt32(reader["trail_sound_id"]),
                            AudioAddress = Convert.ToString(reader["trail_sound_file"])
                        };

                        backgroundSoundClips.Add(soundClip);
                    }
                }
            }
            catch (SqlException e)
            {
                throw;
            }

            return(backgroundSoundClips);
        }
Ejemplo n.º 2
0
        public List <BackgroundSoundClip> GetBackgroundSoundClipsByPanoramicId(int panoramicId)
        {
            List <BackgroundSoundClip> backgroundSoundClips = new List <BackgroundSoundClip>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(@"SELECT ts.* 
                                                      FROM trail_sounds ts 
                                                      INNER JOIN sound_categories sc ON ts.sound_category_id = sc.sound_category_id
                                                      INNER JOIN trail_sounds_associative tsa ON tsa.sound_category_id = sc.sound_category_id 
                                                      WHERE tsa.panoramic_image_id = @panoramicId", conn);
                    cmd.Parameters.AddWithValue("@panoramicId", panoramicId);

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        BackgroundSoundClip soundClip = new BackgroundSoundClip()
                        {
                            AudioId      = Convert.ToInt32(reader["trail_sound_id"]),
                            AudioAddress = Convert.ToString(reader["trail_sound_file"])
                        };

                        backgroundSoundClips.Add(soundClip);
                    }
                }
            }
            catch (SqlException e)
            {
                throw;
            }

            return(backgroundSoundClips);
        }