public void CreateSonglist(SonglistDTO songlistDTO) { if (songlistDTO == null) { throw new ArgumentNullException("Songlist Service - CreateSonglist(...) songlistDTO cannot be null"); } Songlist songlist = Mapper.Map <Songlist>(songlistDTO); using (var uow = UnitOfWorkProvider.Create()) { if (songlistDTO.SongIDs != null) { foreach (int ID in songlistDTO.SongIDs) { if (songlist.Songs == null) { songlist.Songs = new List <Song>(); } Song song = GetSonglistSong(ID); songlist.Songs.Add(song); } } songlist.Owner = GetSonglistCreator(songlistDTO.OwnerID); songlistRepository.Insert(songlist); uow.Commit(); } }
public void CreateSonglist(SongListDTO songListDto, int songId, int playlistId) { using (var uow = UnitOfWorkProvider.Create()) { var songlist = Mapper.Map <SongList>(songListDto); songlist.Playlist = GetSonglistPlaylist(playlistId); songlist.Song = GetSonglistSong(songId); _songlistRepository.Insert(songlist); uow.Commit(); } }