Exemplo n.º 1
0
        public static Playlist Create(PlaylistDto playlistDto)
        {
            Playlist playlist = Mapper.Map <PlaylistDto, Playlist>(playlistDto);

            //  TODO: I could probably leverage backbone's CID property to have the items know of their playlist.
            //  If an unsaved playlist comes from the client with items already in it, the items will not know their playlist's ID.
            //  So, re-map to the playlist as appropriate.

            List <PlaylistItem> improperlyAddedItems = playlist.Items.Where(i => i.Playlist == null).ToList();

            improperlyAddedItems.ForEach(i => playlist.Items.Remove(i));

            playlist.AddItems(improperlyAddedItems);

            return(playlist);
        }
Exemplo n.º 2
0
        public static Playlist Create(PlaylistDto playlistDto, IUserManager userManager, IPlaylistManager playlistManager)
        {
            Playlist playlist = new Playlist
                {
                    Id = playlistDto.Id,
                    Items = PlaylistItem.Create(playlistDto.Items, playlistManager),
                    Sequence = playlistDto.Sequence,
                    Title = playlistDto.Title,
                    User = userManager.Get(playlistDto.UserId)
                };

            //  TODO: This seems unnecessary...
            //  TODO: I could probably leverage backbone's CID property to have the items know of their playlist. Or maybe I should just enforce adding client-side before saving?
            //  If an unsaved playlist comes from the client with items already in it, the items will not know their playlist's ID.
            //  So, re-map to the playlist as appropriate.
            List<PlaylistItem> improperlyAddedItems = playlist.Items.Where(i => i.Playlist == null).ToList();
            improperlyAddedItems.ForEach(i => playlist.Items.Remove(i));
            playlist.AddItems(improperlyAddedItems);

            return playlist;
        }
Exemplo n.º 3
0
        public static Playlist Create(PlaylistDto playlistDto, IUserManager userManager, IPlaylistManager playlistManager)
        {
            Playlist playlist = new Playlist
            {
                Id       = playlistDto.Id,
                Items    = PlaylistItem.Create(playlistDto.Items, playlistManager),
                Sequence = playlistDto.Sequence,
                Title    = playlistDto.Title,
                User     = userManager.Get(playlistDto.UserId)
            };

            //  TODO: This seems unnecessary...
            //  TODO: I could probably leverage backbone's CID property to have the items know of their playlist. Or maybe I should just enforce adding client-side before saving?
            //  If an unsaved playlist comes from the client with items already in it, the items will not know their playlist's ID.
            //  So, re-map to the playlist as appropriate.
            List <PlaylistItem> improperlyAddedItems = playlist.Items.Where(i => i.Playlist == null).ToList();

            improperlyAddedItems.ForEach(i => playlist.Items.Remove(i));
            playlist.AddItems(improperlyAddedItems);

            return(playlist);
        }