small changes around existing series

This commit is contained in:
tidusjar 2016-09-07 21:27:15 +01:00
commit 808134599a

View file

@ -35,6 +35,7 @@ using PlexRequests.Api.Models.Sonarr;
using PlexRequests.Core.SettingModels; using PlexRequests.Core.SettingModels;
using PlexRequests.Store; using PlexRequests.Store;
using System.Linq; using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using PlexRequests.Helpers.Exceptions; using PlexRequests.Helpers.Exceptions;
@ -112,6 +113,12 @@ namespace PlexRequests.UI.Helpers
} }
if (series != null) if (series != null)
{
var requestAll = model.SeasonsRequested.Equals("All", StringComparison.CurrentCultureIgnoreCase);
var first = model.SeasonsRequested.Equals("First", StringComparison.CurrentCultureIgnoreCase);
var latest = model.SeasonsRequested.Equals("Latest", StringComparison.CurrentCultureIgnoreCase);
if (model.SeasonList.Any())
{ {
// Monitor the seasons that we have chosen // Monitor the seasons that we have chosen
foreach (var season in series.seasons) foreach (var season in series.seasons)
@ -121,6 +128,29 @@ namespace PlexRequests.UI.Helpers
season.monitored = true; season.monitored = true;
} }
} }
}
if (requestAll)
{
// Monitor all seasons
foreach (var season in series.seasons)
{
season.monitored = true;
}
}
if (first)
{
var firstSeries = series?.seasons?.OrderBy(x => x.seasonNumber)?.FirstOrDefault() ?? new Season();
firstSeries.monitored = true;
}
if (latest)
{
var lastSeries = series?.seasons?.OrderByDescending(x => x.seasonNumber)?.FirstOrDefault() ?? new Season();
lastSeries.monitored = true;
}
// Update the series in sonarr with the new monitored status // Update the series in sonarr with the new monitored status
SonarrApi.UpdateSeries(series, sonarrSettings.ApiKey, sonarrSettings.FullUri); SonarrApi.UpdateSeries(series, sonarrSettings.ApiKey, sonarrSettings.FullUri);