コード例 #1
0
ファイル: SignUpExecuter.cs プロジェクト: yarden95c/DBProject
        public List <string> AddSongsToUser(User user, List <string> songsNames)
        {
            List <MySqlCommand> commands = new List <MySqlCommand>();
            List <Song>         songs    = new List <Song>();
            List <string>       songsId  = new List <string>();

            foreach (string songName in songsNames)
            {
                Song song = EntitiesFactory.GetSongFromSongName(songName, conn);
                if (song != null)
                {
                    songs.Add(song);
                }
            }

            foreach (Song song in songs)
            {
                commands.Add(GetAddSongCommand(user.Id, song.Id));
                songsId.Add(song.Id);
            }

            conn.ExecuteUpdateCommands(commands);
            return(songsId);
        }