private QuickPlaylist CreateQuickPlaylist(XElement playlistXml) { var id = int.Parse(playlistXml.Attribute(PlaylistId).Value); var title = playlistXml.Attribute(PlaylistTitle).Value; var filterType = (FilterType)Enum.Parse(typeof(FilterType), playlistXml.Attribute(PlaylistFilter).Value); var filterValues = playlistXml.Attribute(PlaylistFilterValue).Value.Split(ValueSeparator); var playlist = new QuickPlaylist(id, title, true, filterType, filterValues); return(playlist); }
private void Play(QuickPlaylist playlist) { var tracks = _trackSearchService.GetTracks(playlist.FilterType, playlist.FilterValues); if (!tracks.Any()) { _messenger.Send(new ShowDialogMessage(_messenger, MessageType.Error, "Auto Playlist Error", "No tracks meet these criteria")); return; } _playRequestHandler.PlayPlaylist(playlist.GetDefaultTitle(), tracks, SortType.Random); }
public void Save(QuickPlaylist playlist) { var xml = _xmlProvider.Get() ?? CreateXmlDocument(); var favouriteQuickPlaylistsXml = xml.Root.Element(PlaylistsFavouriteQuick); if (favouriteQuickPlaylistsXml == null) { favouriteQuickPlaylistsXml = new XElement(PlaylistsFavouriteQuick); xml.Root.Add(favouriteQuickPlaylistsXml); } XElement playlistXml; if (!playlist.Favourite) { playlistXml = favouriteQuickPlaylistsXml .Elements(PropertyNames.Playlist) .Single(pl => pl.Attribute(PlaylistId).Value == playlist.Id.ToString()); playlistXml.Remove(); } else { var playlists = favouriteQuickPlaylistsXml .Elements(PropertyNames.Playlist); var maxId = playlists.Any() ? playlists.Max(pl => Convert.ToInt16(pl.Attribute(PlaylistId).Value)) : 0; playlist.Id = maxId + 1; playlistXml = new XElement(PropertyNames.Playlist); playlistXml.Add(new XAttribute(PlaylistId, playlist.Id)); playlistXml.Add(new XAttribute(PlaylistTitle, playlist.GetDefaultTitle())); playlistXml.Add(new XAttribute(PlaylistFilter, playlist.FilterType.ToString())); playlistXml.Add(new XAttribute(PlaylistFilterValue, string.Join(ValueSeparator.ToString(), playlist.FilterValues))); favouriteQuickPlaylistsXml.Add(playlistXml); } _xmlProvider.Save(xml); }
public QuickPlaylistViewModel(QuickPlaylist playlist) { Playlist = playlist; }
public void Save(QuickPlaylist playlist) { _repository.Save(playlist); }