diff --git a/ServerLib/CWebservice.cs b/ServerLib/CWebservice.cs index 3a085350..1b2762f5 100644 --- a/ServerLib/CWebservice.cs +++ b/ServerLib/CWebservice.cs @@ -376,48 +376,153 @@ namespace ServerLib public SPlaylistData GetPlaylist(int playlistId) { - return CServer.GetPlaylist(playlistId); + try + { + return CServer.GetPlaylist(playlistId); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + + return new SPlaylistData(); + } + } public void AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates) { - if (_CheckRight(EUserRights.AddSongToPlaylist)) + if (!_CheckRight(EUserRights.AddSongToPlaylist)) + return; + + try + { CServer.AddSongToPlaylist(songId, playlistId, allowDuplicates); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + } } public void RemoveSongFromPlaylist(int position, int playlistId, int songId) { - if (_CheckRight(EUserRights.RemoveSongsFromPlaylists)) + if (!_CheckRight(EUserRights.RemoveSongsFromPlaylists)) + return; + + try + { CServer.RemoveSongFromPlaylist(position, playlistId, songId); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + } } public void MoveSongInPlaylist(int newPosition, int playlistId, int songId) { - if (_CheckRight(EUserRights.ReorderPlaylists)) + if (!_CheckRight(EUserRights.ReorderPlaylists)) + return; + + try + { CServer.MoveSongInPlaylist(newPosition, playlistId, songId); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + } } public bool PlaylistContainsSong(int songId, int playlistId) { - return CServer.PlaylistContainsSong(songId, playlistId); + try + { + return CServer.PlaylistContainsSong(songId, playlistId); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + + return false; + } } public SPlaylistSongInfo[] GetPlaylistSongs(int playlistId) { - return CServer.GetPlaylistSongs(playlistId); + try + { + return CServer.GetPlaylistSongs(playlistId); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + return new SPlaylistSongInfo[0]; + } } public void RemovePlaylist(int playlistId) { - if (_CheckRight(EUserRights.DeletePlaylists)) + if (!_CheckRight(EUserRights.DeletePlaylists)) + return; + + try + { CServer.RemovePlaylist(playlistId); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + } } public int AddPlaylist(string playlistName) { - if (_CheckRight(EUserRights.CreatePlaylists)) - return CServer.AddPlaylist(playlistName); + if (!_CheckRight(EUserRights.CreatePlaylists)) return -1; + + try + { + return CServer.AddPlaylist(playlistName); + } + catch (ArgumentException e) + { + if (WebOperationContext.Current != null) + { + WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden; + WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; + } + + return -1; + } } #endregion diff --git a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs index 77fc2b06..fdddf0dc 100644 --- a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs +++ b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs @@ -43,7 +43,7 @@ namespace Vocaluxe.Lib.Playlist public void Save() { - if (File == "") + if (string.IsNullOrEmpty(File)) { string filename = string.Empty; // ReSharper disable LoopCanBeConvertedToQuery diff --git a/Vocaluxe/Website/js/main.js b/Vocaluxe/Website/js/main.js index 49aec6f1..b51c9841 100644 --- a/Vocaluxe/Website/js/main.js +++ b/Vocaluxe/Website/js/main.js @@ -46,6 +46,10 @@ data.timeout = 10000; //10 sec. timeout } + if ((typeof data.type) == "undefined") { + data.type = "GET"; + } + if (message != "noOverlay") { var message2 = message; if (i18n.t) { @@ -585,6 +589,7 @@ url: "sendPhoto", contentType: "application/json;charset=utf-8", type: "POST", + timeout: 40000, data: JSON.stringify({ Photo: { base64Data: imgData } }) }, 'Uploading photo...'); } @@ -1226,7 +1231,7 @@ if (name != null && name.replace(" ", "") != "" && $('h2').filter(function () { return this.textContent == name; }).length == 0) { - request({ url: "addPlaylist?playlistName=" + name }, "Creating...").done(function () { + request({ url: "addPlaylist?playlistName=" + name, dataType: "json" }, "Creating...").done(function () { request({ url: "getPlaylists" }).done(function (data2) { diff --git a/Vocaluxe/app.config b/Vocaluxe/app.config index 7fb031b0..c0dafe77 100644 --- a/Vocaluxe/app.config +++ b/Vocaluxe/app.config @@ -3,4 +3,32 @@ +