From 4c59e9d19c298f7a26848e2d70b2eeb4d6abc365 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 25 Apr 2016 17:01:39 +0100 Subject: [PATCH] #27 added TV Search to the notification --- PlexRequests.UI/Content/search.js | 5 ++++- PlexRequests.UI/Modules/SearchModule.cs | 13 +++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/PlexRequests.UI/Content/search.js b/PlexRequests.UI/Content/search.js index 363e79689..55de573eb 100644 --- a/PlexRequests.UI/Content/search.js +++ b/PlexRequests.UI/Content/search.js @@ -78,9 +78,12 @@ $(function () { if (seasons === "1") { // Send over the first season data = data + "&seasons=first"; - } + var $notify = $('#notifyUser').is(':checked'); + + data = data + "¬ify=" + $notify; + var type = $form.prop('method'); var url = $form.prop('action'); diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs index 8f9e1ed4c..07c96bf49 100644 --- a/PlexRequests.UI/Modules/SearchModule.cs +++ b/PlexRequests.UI/Modules/SearchModule.cs @@ -98,7 +98,7 @@ namespace PlexRequests.UI.Modules Get["movie/playing"] = parameters => CurrentlyPlayingMovies(); Post["request/movie"] = parameters => RequestMovie((int)Request.Form.movieId, (bool)Request.Form.notify); - Post["request/tv"] = parameters => RequestTvShow((int)Request.Form.tvId, (string)Request.Form.seasons); + Post["request/tv"] = parameters => RequestTvShow((int)Request.Form.tvId, (string)Request.Form.seasons, (bool)Request.Form.notify); Post["request/album"] = parameters => RequestAlbum((string)Request.Form.albumId); } private IPlexApi PlexApi { get; } @@ -568,8 +568,9 @@ namespace PlexRequests.UI.Modules /// /// The show identifier. /// The seasons. + /// if set to true [notify]. /// - private Response RequestTvShow(int showId, string seasons) + private Response RequestTvShow(int showId, string seasons, bool notify) { var tvApi = new TvMazeApi(); @@ -589,6 +590,10 @@ namespace PlexRequests.UI.Modules // check if the current user is already marked as a requester for this show, if not, add them if (!existingRequest.UserHasRequested(Username)) { + if (notify) + { + existingRequest.AddUserToNotification(Username); + } existingRequest.RequestedUsers.Add(Username); RequestService.UpdateRequest(existingRequest); } @@ -626,6 +631,10 @@ namespace PlexRequests.UI.Modules ImdbId = showInfo.externals?.imdb ?? string.Empty, SeasonCount = showInfo.seasonCount }; + if (notify) + { + model.AddUserToNotification(Username); + } var seasonsList = new List(); switch (seasons) {