Exemplo n.º 1
0
        public List <int> AddArtistsToUser(User user, List <string> artistsNames)
        {
            List <MySqlCommand> commands  = new List <MySqlCommand>();
            List <Artist>       artists   = new List <Artist>();
            List <int>          artistsId = new List <int>();

            foreach (string artistName in artistsNames)
            {
                Artist artist = EntitiesFactory.GetArtistFromArtistName(artistName, conn);
                if (artist != null)
                {
                    artists.Add(artist);
                }
            }

            foreach (Artist artist in artists)
            {
                commands.Add(GetAddArtistCommand(user.Id, artist.Id));
                artistsId.Add(int.Parse(artist.Id));
            }

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