Example #1
0
        public EditPlaylistViewModel(Playlist playlist, User user)
        {
            Playlist = playlist;
            User     = user;

            _songRepo     = new SongRepository();
            _artRepo      = new ArtRepository();
            _playlistRepo = new PlaylistRepository();
            _playlistRepo.Dispose();

            Art              = new ObservableCollection <string>(_artRepo.GetPlaylistArt());
            AllSongs         = new ObservableCollection <Song>(_songRepo.GetAllSongs());
            PlaceholderSongs = CurrentSongs;

            Title          = Playlist.Title;
            Image          = Playlist.Image;
            PlaylistUserID = Playlist.UserID;
            SelectedImage  = Playlist.Image;

            // COMMANDS
            AddSongToPlaylistCommand      = new RelayCommand(new Action <object>(AddSongToPlaylist));
            RemoveSongFromPlaylistCommand = new RelayCommand(new Action <object>(RemoveSongFromPlaylist));
            CloseEditPlaylistViewCommand  = new RelayCommand(new Action <object>(CloseEditPlaylistView));
            SavePlaylistChangesCommand    = new RelayCommand(new Action <object>(SavePlaylistChanges), Predicate => {
                if (TitleRule.TitleRegex.IsMatch(Title))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });
        }
        public EditPlaylistViewModel(Playlist playlist, User user)
        {
            Playlist = playlist;
            User = user;

            _songRepo = new SongRepository();
            _artRepo = new ArtRepository();
            _playlistRepo = new PlaylistRepository();
            _playlistRepo.Dispose();

            Art = new ObservableCollection<string>(_artRepo.GetPlaylistArt());
            AllSongs = new ObservableCollection<Song>(_songRepo.GetAllSongs());
            PlaceholderSongs = CurrentSongs;

            Title = Playlist.Title;
            Image = Playlist.Image;
            PlaylistUserID = Playlist.UserID;
            SelectedImage = Playlist.Image;

            // COMMANDS
            AddSongToPlaylistCommand = new RelayCommand(new Action<object>(AddSongToPlaylist));
            RemoveSongFromPlaylistCommand = new RelayCommand(new Action<object>(RemoveSongFromPlaylist));
            CloseEditPlaylistViewCommand = new RelayCommand(new Action<object>(CloseEditPlaylistView));
            SavePlaylistChangesCommand = new RelayCommand(new Action<object>(SavePlaylistChanges), Predicate => {
                if (TitleRule.TitleRegex.IsMatch(Title))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            });
        }
        private void CreatePlaylist(Object obj)
        {
            PlaylistRepository tempRepo = new PlaylistRepository();
            tempRepo.Dispose();

            ObservableCollection<Song> tempSongs = new ObservableCollection<Song>(SelectedSongs);
            Playlist newPlaylist = new Playlist();
            newPlaylist.Title = Name;
            newPlaylist.Image = PathHelper.GetRelativePath(SelectedImage, Directory.GetCurrentDirectory() + "\\");
            newPlaylist.Songs = tempSongs;
            newPlaylist.UserID = PlaylistForAll ? 0 : User.ID;

            tempRepo.AddNewPlaylist(newPlaylist, newPlaylist.UserID);

            //Listened to by mainviewmodel
            Messenger.Default.Send<bool>(true, "CloseCreatePlaylistView");
        }
Example #4
0
        private void CreatePlaylist(Object obj)
        {
            PlaylistRepository tempRepo = new PlaylistRepository();

            tempRepo.Dispose();

            ObservableCollection <Song> tempSongs = new ObservableCollection <Song>(SelectedSongs);
            Playlist newPlaylist = new Playlist();

            newPlaylist.Title  = Name;
            newPlaylist.Image  = PathHelper.GetRelativePath(SelectedImage, Directory.GetCurrentDirectory() + "\\");
            newPlaylist.Songs  = tempSongs;
            newPlaylist.UserID = PlaylistForAll ? 0 : User.ID;

            tempRepo.AddNewPlaylist(newPlaylist, newPlaylist.UserID);

            //Listened to by mainviewmodel
            Messenger.Default.Send <bool>(true, "CloseCreatePlaylistView");
        }