public List <PlaylistEntryModel> GetMyStations() { Dictionary <string, string> data = new Dictionary <string, string>(); data.Add("format", "text"); data.Add("separator", "|"); data.Add("only_url", "no"); string response = webController.RequestString("get_all_stations", data); return(PlaylistEntryModel.GetPlaylistEntrysByText(response)); }
private void AddPlaylistListItem(PlaylistEntryModel playlistEntry) { if (listViewPlaylist.Items.Find(playlistEntry.ProxyId, false).Length != 0) { return; } ListViewItem item = new ListViewItem(playlistEntry.Title); item.Name = playlistEntry.ProxyId; item.Tag = playlistEntry; listViewPlaylist.Items.Add(item); }
private void OpenPlaylistFromSelection() { if (!downloadAvaible) { return; } if (listViewPlaylist.SelectedItems.Count == 0) { return; } PlaylistEntryModel playlistEntry = (PlaylistEntryModel)listViewPlaylist.SelectedItems[0].Tag; OpenPlaylist(playlistEntry); listViewPlaylist.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }
private void OpenPlaylist(PlaylistEntryModel playlistEntry) { if (!downloadAvaible) { return; } ClearResultList(); Cursor.Current = Cursors.WaitCursor; List <MusicEntryModel> musicEntrys = ProxyApiController.Instance.GetMusicByPlaylist(playlistEntry); Cursor.Current = Cursors.Default; if (musicEntrys == null || musicEntrys.Count == 0) { return; } foreach (MusicEntryModel musicEntry in musicEntrys) { AddResultListItem(musicEntry); } listViewResult.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); tabControlSR.SelectedTab = tabPageResult; }
public IActionResult CreateEntry(Int32?id, [FromBody] PlaylistEntryModel model) { try { LoggerBundle.Trace("Registered PUT request on PlaylistsController.CreateEntry"); if (!IsAuthorized(out IActionResult result)) { LoggerBundle.Trace("Request not authorized"); return(result); } // validate if (!id.HasValue) { LoggerBundle.Trace("Validation failed: id is null"); return(StatusCode((Int32)HttpStatusCode.BadRequest)); } if (null == model) { LoggerBundle.Trace("Validation failed: model is null"); return(StatusCode((Int32)HttpStatusCode.BadRequest)); } Int32?trackId = model.TrackId; if (!trackId.HasValue) { LoggerBundle.Trace("Validation failed: track identifier is null"); return(StatusCode((Int32)HttpStatusCode.BadRequest)); } String title = model.Title?.Trim(); if (String.IsNullOrWhiteSpace(title)) { LoggerBundle.Trace("Validation failed: invalid title"); return(StatusCode((Int32)HttpStatusCode.BadRequest)); } // get data using (DataContext dc = DataContextFactory.GetInstance()) { dc.SetUsers.Attach(AuthorizedUser); Track track = dc.SetTracks.FirstOrDefault(x => x.UniqueId.Equals(trackId)); if (null == track) { LoggerBundle.Trace($"Validation failed: no track found for given id '{trackId}'"); return(StatusCode((Int32)HttpStatusCode.NotFound)); } Playlist playlist = dc.SetPlaylists.Include(x => x.CreateUser) .Include(x => x.PlaylistEntries) .ThenInclude(x => x.Track) .Include(x => x.PlaylistEntries) .ThenInclude(x => x.CreateUser) .Include(x => x.PlaylistPermissions) .ThenInclude(x => x.User) .Where(x => x.CreateUser.UniqueId.Equals(AuthorizedUser.UniqueId) || x.PlaylistPermissions.Any(y => y.User.UniqueId.Equals(AuthorizedUser.UniqueId) && y.CanModify)) .FirstOrDefault(x => x.UniqueId.Equals(id)); if (null == playlist) { LoggerBundle.Trace($"Validation failed: no playlist found for given id '{id}'"); return(StatusCode((Int32)HttpStatusCode.NotFound)); } PlaylistEntry entry = new PlaylistEntry { CreateUser = AuthorizedUser , Title = title , Track = track , Playlist = playlist }; dc.SetPlaylistEntries.Add(entry); dc.SaveChanges(); return(Ok(playlist.ToJsonDictionary())); } } catch (Exception ex) { return(HandleException(ex)); } }
public List <MusicEntryModel> GetMusicByPlaylist(PlaylistEntryModel playlistEntry) { string response = webController.RequestString(playlistEntry.ProxyPath); return(MusicEntryModel.GetMusicEntrysByM3U(response)); }