public void EditSonglist(SonglistDTO songlistDTO, List <int> songIds) { if (songlistDTO == null) { throw new ArgumentNullException("Songlist Service - EditSonglist(...) songlistDTO cannot be null"); } using (var uow = UnitOfWorkProvider.Create()) { var songlist = songlistRepository.GetByID(songlistDTO.ID); if (songIds != null && songIds.Any()) { var songs = songRepository.GetByIDs(songIds); songlist.Songs.RemoveAll(song => !songs.Contains(song)); songlist.Songs.AddRange( songs.Where(song => !songlist.Songs.Contains(song))); } else { songlist.Songs.Clear(); } songlistRepository.Update(songlist); uow.Commit(); } }
public void EditSonglist(SongListDTO songListDto, int songId, int playlistId) { using (var uow = UnitOfWorkProvider.Create()) { var songlist = _songlistRepository.GetById(songListDto.ID); Mapper.Map(songListDto, songlist); songlist.Playlist = GetSonglistPlaylist(playlistId); songlist.Song = GetSonglistSong(songId); _songlistRepository.Update(songlist); uow.Commit(); } }