1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-11-01 16:32:56 +01:00
Sonarr/NzbDrone.Web/Controllers/SettingsController.cs

619 lines
27 KiB
C#
Raw Normal View History

2010-09-23 05:19:47 +02:00
using System;
using System.Collections.Generic;
using System.IO;
2010-09-23 05:19:47 +02:00
using System.Linq;
using System.Web.Mvc;
using NLog;
2011-11-13 08:27:16 +01:00
using NzbDrone.Common;
using NzbDrone.Common.Model;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
2011-04-04 05:50:12 +02:00
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
2010-09-24 07:21:45 +02:00
using NzbDrone.Web.Models;
2010-09-23 05:19:47 +02:00
namespace NzbDrone.Web.Controllers
{
[HandleError]
2010-09-23 05:19:47 +02:00
public class SettingsController : Controller
{
2011-04-10 04:44:01 +02:00
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider;
private readonly IndexerProvider _indexerProvider;
private readonly QualityProvider _qualityProvider;
2011-04-25 09:42:29 +02:00
private readonly AutoConfigureProvider _autoConfigureProvider;
private readonly SeriesProvider _seriesProvider;
private readonly ExternalNotificationProvider _externalNotificationProvider;
private readonly QualityTypeProvider _qualityTypeProvider;
private readonly RootDirProvider _rootDirProvider;
private readonly ConfigFileProvider _configFileProvider;
private readonly NewznabProvider _newznabProvider;
2010-09-24 07:21:45 +02:00
public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider,
2011-08-08 23:50:48 +02:00
QualityProvider qualityProvider, AutoConfigureProvider autoConfigureProvider,
SeriesProvider seriesProvider, ExternalNotificationProvider externalNotificationProvider,
QualityTypeProvider qualityTypeProvider, RootDirProvider rootDirProvider,
ConfigFileProvider configFileProvider, NewznabProvider newznabProvider)
2010-09-24 07:21:45 +02:00
{
_externalNotificationProvider = externalNotificationProvider;
_qualityTypeProvider = qualityTypeProvider;
_rootDirProvider = rootDirProvider;
_configFileProvider = configFileProvider;
_newznabProvider = newznabProvider;
_configProvider = configProvider;
_indexerProvider = indexerProvider;
_qualityProvider = qualityProvider;
2011-04-25 09:42:29 +02:00
_autoConfigureProvider = autoConfigureProvider;
_seriesProvider = seriesProvider;
2010-09-24 07:21:45 +02:00
}
2010-09-23 05:19:47 +02:00
public ActionResult Test()
{
return View();
}
public JsonResult TestResults(string q)
{
var results = new List<TvDbSearchResultModel>();
results.Add(new TvDbSearchResultModel { Id = 1, Title = "30 Rock", FirstAired = DateTime.Today.ToShortDateString() });
results.Add(new TvDbSearchResultModel { Id = 2, Title = "The Office", FirstAired = DateTime.Today.AddDays(-1).ToShortDateString() });
return Json(results, JsonRequestBehavior.AllowGet );
}
2011-07-01 22:33:03 +02:00
public ActionResult Index()
2010-09-23 05:19:47 +02:00
{
2011-07-01 22:33:03 +02:00
return RedirectToAction("Indexers");
}
public ActionResult Indexers()
{
2011-07-01 22:33:03 +02:00
return View(new IndexerSettingsModel
2011-08-08 23:50:48 +02:00
{
NzbMatrixUsername = _configProvider.NzbMatrixUsername,
NzbMatrixApiKey = _configProvider.NzbMatrixApiKey,
2011-08-08 23:50:48 +02:00
NzbsrusUId = _configProvider.NzbsrusUId,
NzbsrusHash = _configProvider.NzbsrusHash,
2011-08-08 23:50:48 +02:00
NzbsOrgHash = _configProvider.NzbsOrgHash,
NzbsOrgUId = _configProvider.NzbsOrgUId,
2011-08-08 23:50:48 +02:00
NewzbinUsername = _configProvider.NewzbinUsername,
NewzbinPassword = _configProvider.NewzbinPassword,
2011-08-08 23:50:48 +02:00
NzbsOrgEnabled = _indexerProvider.GetSettings(typeof(NzbsOrg)).Enable,
NzbMatrixEnabled = _indexerProvider.GetSettings(typeof(NzbMatrix)).Enable,
NzbsRUsEnabled = _indexerProvider.GetSettings(typeof(NzbsRUs)).Enable,
NewzbinEnabled = _indexerProvider.GetSettings(typeof(Newzbin)).Enable,
NewznabEnabled = _indexerProvider.GetSettings(typeof(Newznab)).Enable,
NewznabDefinitions = _newznabProvider.All(),
2011-08-08 23:50:48 +02:00
});
}
public ActionResult Sabnzbd()
{
var tvCategory = _configProvider.SabTvCategory;
var tvCategorySelectList = new SelectList(new[] { tvCategory });
var model = new SabnzbdSettingsModel
{
SabHost = _configProvider.SabHost,
2011-08-08 23:50:48 +02:00
SabPort = _configProvider.SabPort,
SabApiKey = _configProvider.SabApiKey,
SabUsername = _configProvider.SabUsername,
SabPassword = _configProvider.SabPassword,
2011-11-03 03:44:22 +01:00
SabTvCategory = tvCategory,
SabTvPriority = _configProvider.SabTvPriority,
SabDropDirectory = _configProvider.SabDropDirectory,
SabTvCategorySelectList = tvCategorySelectList
};
return View(model);
}
public ActionResult Quality()
{
var qualityTypes = new List<QualityTypes>();
foreach (QualityTypes qual in Enum.GetValues(typeof(QualityTypes)))
{
qualityTypes.Add(qual);
}
ViewData["Qualities"] = qualityTypes;
2011-07-08 07:41:08 +02:00
var profiles = _qualityProvider.All().ToList();
foreach (var qualityProfile in profiles)
{
qualityProfile.AllowedString = string.Join(",", qualityProfile.Allowed);
}
var defaultQualityQualityProfileId = Convert.ToInt32(_configProvider.DefaultQualityProfile);
var qualityProfileSelectList = new SelectList(profiles, "QualityProfileId", "Name");
var qualityTypesFromDb = _qualityTypeProvider.All();
var model = new QualityModel
2011-04-10 04:44:01 +02:00
{
Profiles = profiles,
DefaultQualityProfileId = defaultQualityQualityProfileId,
QualityProfileSelectList = qualityProfileSelectList,
SdtvMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 1).MaxSize,
DvdMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 2).MaxSize,
HdtvMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 4).MaxSize,
WebdlMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 5).MaxSize,
Bluray720pMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 6).MaxSize,
Bluray1080pMaxSize = qualityTypesFromDb.Single(q => q.QualityTypeId == 7).MaxSize
2011-04-10 04:44:01 +02:00
};
return View(model);
}
public ActionResult Notifications()
{
var model = new NotificationSettingsModel
2011-04-10 04:44:01 +02:00
{
XbmcEnabled = _externalNotificationProvider.GetSettings(typeof(Xbmc)).Enable,
XbmcNotifyOnGrab = _configProvider.XbmcNotifyOnGrab,
XbmcNotifyOnDownload = _configProvider.XbmcNotifyOnDownload,
XbmcUpdateLibrary = _configProvider.XbmcUpdateLibrary,
XbmcCleanLibrary = _configProvider.XbmcCleanLibrary,
XbmcHosts = _configProvider.XbmcHosts,
XbmcUsername = _configProvider.XbmcUsername,
XbmcPassword = _configProvider.XbmcPassword,
SmtpEnabled = _externalNotificationProvider.GetSettings(typeof(Smtp)).Enable,
SmtpNotifyOnGrab = _configProvider.SmtpNotifyOnGrab,
SmtpNotifyOnDownload = _configProvider.SmtpNotifyOnGrab,
SmtpServer = _configProvider.SmtpServer,
SmtpPort = _configProvider.SmtpPort,
SmtpUseSsl = _configProvider.SmtpUseSsl,
SmtpUsername = _configProvider.SmtpUsername,
SmtpPassword = _configProvider.SmtpPassword,
SmtpFromAddress = _configProvider.SmtpFromAddress,
SmtpToAddresses = _configProvider.SmtpToAddresses,
TwitterEnabled = _externalNotificationProvider.GetSettings(typeof(Twitter)).Enable,
TwitterNotifyOnGrab = _configProvider.TwitterNotifyOnGrab,
2011-11-02 08:09:52 +01:00
TwitterNotifyOnDownload = _configProvider.TwitterNotifyOnDownload,
GrowlEnabled = _externalNotificationProvider.GetSettings(typeof(Growl)).Enable,
GrowlNotifyOnGrab = _configProvider.GrowlNotifyOnGrab,
GrowlNotifyOnDownload = _configProvider.GrowlNotifyOnDownload,
GrowlHost = _configProvider.GrowlHost,
2011-11-03 03:44:22 +01:00
GrowlPassword = _configProvider.GrowlPassword,
ProwlEnabled = _externalNotificationProvider.GetSettings(typeof(Prowl)).Enable,
ProwlNotifyOnGrab = _configProvider.ProwlNotifyOnGrab,
ProwlNotifyOnDownload = _configProvider.ProwlNotifyOnDownload,
ProwlApiKeys = _configProvider.ProwlApiKeys,
ProwlPriority = _configProvider.ProwlPriority,
ProwlPrioritySelectList = GetProwlPrioritySelectList()
2011-04-10 04:44:01 +02:00
};
2011-07-01 22:33:03 +02:00
return View(model);
}
public ActionResult EpisodeSorting()
{
var model = new EpisodeSortingModel();
2011-07-08 05:36:02 +02:00
model.SeriesName = _configProvider.SortingIncludeSeriesName;
2011-07-08 05:57:44 +02:00
model.EpisodeName = _configProvider.SortingIncludeEpisodeTitle;
2011-07-08 05:36:02 +02:00
model.ReplaceSpaces = _configProvider.SortingReplaceSpaces;
model.AppendQuality = _configProvider.SortingAppendQuality;
model.SeasonFolders = _configProvider.UseSeasonFolder;
2011-07-08 05:36:02 +02:00
model.SeasonFolderFormat = _configProvider.SortingSeasonFolderFormat;
model.SeparatorStyle = _configProvider.SortingSeparatorStyle;
model.NumberStyle = _configProvider.SortingNumberStyle;
model.MultiEpisodeStyle = _configProvider.SortingMultiEpisodeStyle;
model.SeparatorStyles = new SelectList(EpisodeSortingHelper.GetSeparatorStyles(), "Id", "Name");
model.NumberStyles = new SelectList(EpisodeSortingHelper.GetNumberStyles(), "Id", "Name");
model.MultiEpisodeStyles = new SelectList(EpisodeSortingHelper.GetMultiEpisodeStyles(), "Id", "Name");
2011-07-01 22:33:03 +02:00
return View(model);
}
public ActionResult System()
{
var selectedAuthenticationType = _configFileProvider.AuthenticationType;
var authenticationTypes = new List<AuthenticationType>();
foreach (AuthenticationType authenticationType in Enum.GetValues(typeof(AuthenticationType)))
{
authenticationTypes.Add(authenticationType);
}
var authTypeSelectList = new SelectList(authenticationTypes, selectedAuthenticationType);
var model = new SystemSettingsModel();
model.Port = _configFileProvider.Port;
model.LaunchBrowser = _configFileProvider.LaunchBrowser;
model.AuthenticationType = selectedAuthenticationType;
model.AuthTypeSelectList = authTypeSelectList;
return View(model);
}
public ViewResult AddProfile()
{
var qualityTypes = new List<QualityTypes>();
foreach (QualityTypes qual in Enum.GetValues(typeof(QualityTypes)))
{
qualityTypes.Add(qual);
}
ViewData["Qualities"] = qualityTypes;
var qualityProfile = new QualityProfile
{
Name = "New Profile",
Allowed = new List<QualityTypes> { QualityTypes.Unknown },
Cutoff = QualityTypes.Unknown
};
var id = _qualityProvider.Add(qualityProfile);
qualityProfile.QualityProfileId = id;
qualityProfile.AllowedString = "Unknown";
ViewData["ProfileId"] = id;
return View("QualityProfileItem", qualityProfile);
}
public ActionResult GetQualityProfileView(QualityProfile profile)
{
var qualityTypes = new List<QualityTypes>();
foreach (QualityTypes qual in Enum.GetValues(typeof(QualityTypes)))
{
qualityTypes.Add(qual);
}
ViewData["Qualities"] = qualityTypes;
ViewData["ProfileId"] = profile.QualityProfileId;
return PartialView("QualityProfileItem", profile);
}
public JsonResult DeleteQualityProfile(int profileId)
{
try
{
if (_seriesProvider.GetAllSeries().Where(s => s.QualityProfileId == profileId).Count() != 0)
return new JsonResult { Data = "Unable to delete Profile, it is still in use." };
_qualityProvider.Delete(profileId);
}
catch (Exception)
{
return new JsonResult { Data = "failed" };
}
return new JsonResult { Data = "ok" };
}
2011-11-16 00:11:17 +01:00
public PartialViewResult AddNewznabProvider()
{
var newznab = new NewznabDefinition
{
Enable = false,
Name = "Newznab Provider"
};
var id = _newznabProvider.Save(newznab);
newznab.Id = id;
ViewData["ProviderId"] = id;
2011-11-16 00:11:17 +01:00
return PartialView("NewznabProvider", newznab);
}
public ActionResult GetNewznabProviderView(NewznabDefinition provider)
{
ViewData["ProviderId"] = provider.Id;
return PartialView("NewznabProvider", provider);
}
public JsonResult DeleteNewznabProvider(int providerId)
{
try
{
_newznabProvider.Delete(providerId);
}
catch (Exception)
{
return new JsonResult { Data = "failed" };
}
return new JsonResult { Data = "ok" };
}
public ActionResult SubMenu()
{
return PartialView();
}
public QualityModel GetUpdatedProfileList()
{
var profiles = _qualityProvider.All().ToList();
var defaultQualityQualityProfileId =
Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId));
var selectList = new SelectList(profiles, "QualityProfileId", "Name");
return new QualityModel { DefaultQualityProfileId = defaultQualityQualityProfileId, QualityProfileSelectList = selectList };
}
public JsonResult AutoConfigureSab()
2011-04-25 09:42:29 +02:00
{
try
{
var info = _autoConfigureProvider.AutoConfigureSab();
return Json(info, JsonRequestBehavior.AllowGet);
2011-04-25 09:42:29 +02:00
}
catch (Exception)
{
return new JsonResult { Data = "failed" };
}
}
2011-08-08 23:50:48 +02:00
2010-09-24 07:21:45 +02:00
[HttpPost]
2011-08-08 23:50:48 +02:00
public JsonResult SaveIndexers(IndexerSettingsModel data)
2010-09-24 07:21:45 +02:00
{
if (ModelState.IsValid)
2010-09-24 07:21:45 +02:00
{
var nzbsOrgSettings = _indexerProvider.GetSettings(typeof(NzbsOrg));
nzbsOrgSettings.Enable = data.NzbsOrgEnabled;
_indexerProvider.SaveSettings(nzbsOrgSettings);
var nzbMatrixSettings = _indexerProvider.GetSettings(typeof(NzbMatrix));
nzbMatrixSettings.Enable = data.NzbMatrixEnabled;
_indexerProvider.SaveSettings(nzbMatrixSettings);
var nzbsRUsSettings = _indexerProvider.GetSettings(typeof(NzbsRUs));
nzbsRUsSettings.Enable = data.NzbsRUsEnabled;
_indexerProvider.SaveSettings(nzbsRUsSettings);
var newzbinSettings = _indexerProvider.GetSettings(typeof(Newzbin));
newzbinSettings.Enable = data.NewzbinEnabled;
_indexerProvider.SaveSettings(newzbinSettings);
var newznabSettings = _indexerProvider.GetSettings(typeof(Newznab));
newznabSettings.Enable = data.NewznabEnabled;
_indexerProvider.SaveSettings(newznabSettings);
_configProvider.NzbsOrgUId = data.NzbsOrgUId;
_configProvider.NzbsOrgHash = data.NzbsOrgHash;
_configProvider.NzbMatrixUsername = data.NzbMatrixUsername;
_configProvider.NzbMatrixApiKey = data.NzbMatrixApiKey;
_configProvider.NzbsrusUId = data.NzbsrusUId;
_configProvider.NzbsrusHash = data.NzbsrusHash;
_configProvider.NewzbinUsername = data.NewzbinUsername;
_configProvider.NewzbinPassword = data.NewzbinPassword;
if (data.NewznabDefinitions != null)
_newznabProvider.SaveAll(data.NewznabDefinitions);
2011-08-08 23:50:48 +02:00
return GetSuccessResult();
}
2011-08-08 23:50:48 +02:00
return GetInvalidModelResult();
2010-09-23 05:19:47 +02:00
}
[HttpPost]
2011-08-08 23:50:48 +02:00
public JsonResult SaveSabnzbd(SabnzbdSettingsModel data)
{
if (ModelState.IsValid)
{
//Check to see if the TV Directory matches any RootDirs (Ignoring Case), if it does, return an error to the user
//This prevents a user from finding a way to delete their entire TV Library
var rootDirs = _rootDirProvider.GetAll();
if (rootDirs.Any(r => r.Path.Equals(data.SabDropDirectory, StringComparison.InvariantCultureIgnoreCase)))
Json(new NotificationResult { Title = "Failed", Text = "Invalid TV Directory", NotificationType = NotificationType.Error });
_configProvider.SabHost = data.SabHost;
_configProvider.SabPort = data.SabPort;
_configProvider.SabApiKey = data.SabApiKey;
_configProvider.SabPassword = data.SabPassword;
_configProvider.SabTvCategory = data.SabTvCategory;
_configProvider.SabUsername = data.SabUsername;
_configProvider.SabTvPriority = data.SabTvPriority;
_configProvider.SabDropDirectory = data.SabDropDirectory;
2011-08-08 23:50:48 +02:00
return GetSuccessResult();
}
2011-08-08 23:50:48 +02:00
return
Json(new NotificationResult() { Title = "Failed", Text = "Invalid request data.", NotificationType = NotificationType.Error });
}
[HttpPost]
2011-08-22 03:00:12 +02:00
public JsonResult SaveQuality(QualityModel data)
{
if (ModelState.IsValid)
{
_configProvider.DefaultQualityProfile = data.DefaultQualityProfileId;
//Saves only the Default Quality, skips User Profiles since none exist
if (data.Profiles == null)
2011-08-08 23:50:48 +02:00
return GetSuccessResult();
foreach (var profile in data.Profiles)
{
Logger.Debug(String.Format("Updating Profile: {0}", profile));
profile.Allowed = new List<QualityTypes>();
//Remove the extra comma from the end
profile.AllowedString = profile.AllowedString.Trim(',');
foreach (var quality in profile.AllowedString.Split(','))
{
var qType = (QualityTypes)Enum.Parse(typeof(QualityTypes), quality);
profile.Allowed.Add(qType);
}
//If the Cutoff value selected is not in the allowed list then use the last allowed value, this should be validated on submit
if (!profile.Allowed.Contains(profile.Cutoff))
2011-08-22 03:00:12 +02:00
return GetInvalidModelResult();
//profile.Cutoff = profile.Allowed.Last();
_qualityProvider.Update(profile);
}
var qualityTypesFromDb = _qualityTypeProvider.All();
qualityTypesFromDb.Single(q => q.QualityTypeId == 1).MaxSize = data.SdtvMaxSize;
qualityTypesFromDb.Single(q => q.QualityTypeId == 2).MaxSize = data.DvdMaxSize;
qualityTypesFromDb.Single(q => q.QualityTypeId == 4).MaxSize = data.HdtvMaxSize;
qualityTypesFromDb.Single(q => q.QualityTypeId == 5).MaxSize = data.WebdlMaxSize;
qualityTypesFromDb.Single(q => q.QualityTypeId == 6).MaxSize = data.Bluray720pMaxSize;
qualityTypesFromDb.Single(q => q.QualityTypeId == 7).MaxSize = data.Bluray1080pMaxSize;
_qualityTypeProvider.UpdateAll(qualityTypesFromDb);
2011-08-08 23:50:48 +02:00
return GetSuccessResult();
}
2011-08-08 23:50:48 +02:00
return GetInvalidModelResult();
}
[HttpPost]
2011-08-22 03:00:12 +02:00
public JsonResult SaveNotifications(NotificationSettingsModel data)
{
if (ModelState.IsValid)
{
//XBMC Enabled
var xbmcSettings = _externalNotificationProvider.GetSettings(typeof(Xbmc));
xbmcSettings.Enable = data.XbmcEnabled;
_externalNotificationProvider.SaveSettings(xbmcSettings);
_configProvider.XbmcNotifyOnGrab = data.XbmcNotifyOnGrab;
_configProvider.XbmcNotifyOnDownload = data.XbmcNotifyOnDownload;
_configProvider.XbmcUpdateLibrary = data.XbmcUpdateLibrary;
_configProvider.XbmcCleanLibrary = data.XbmcCleanLibrary;
_configProvider.XbmcHosts = data.XbmcHosts;
_configProvider.XbmcUsername = data.XbmcUsername;
_configProvider.XbmcPassword = data.XbmcPassword;
//SMTP
var smtpSettings = _externalNotificationProvider.GetSettings(typeof (Smtp));
smtpSettings.Enable = data.SmtpEnabled;
_externalNotificationProvider.SaveSettings(smtpSettings);
_configProvider.SmtpNotifyOnGrab = data.SmtpNotifyOnGrab;
_configProvider.SmtpNotifyOnDownload = data.SmtpNotifyOnDownload;
_configProvider.SmtpServer = data.SmtpServer;
_configProvider.SmtpPort = data.SmtpPort;
_configProvider.SmtpUseSsl = data.SmtpUseSsl;
_configProvider.SmtpUsername = data.SmtpUsername;
_configProvider.SmtpPassword = data.SmtpPassword;
_configProvider.SmtpFromAddress = data.SmtpFromAddress;
_configProvider.SmtpToAddresses = data.SmtpToAddresses;
//Twitter
var twitterSettings = _externalNotificationProvider.GetSettings(typeof(Twitter));
twitterSettings.Enable = data.TwitterEnabled;
_externalNotificationProvider.SaveSettings(twitterSettings);
_configProvider.TwitterNotifyOnGrab = data.TwitterNotifyOnGrab;
_configProvider.TwitterNotifyOnDownload = data.TwitterNotifyOnDownload;
2011-11-02 08:09:52 +01:00
//Growl
var growlSettings = _externalNotificationProvider.GetSettings(typeof(Growl));
growlSettings.Enable = data.GrowlEnabled;
_externalNotificationProvider.SaveSettings(growlSettings);
_configProvider.GrowlNotifyOnGrab = data.GrowlNotifyOnGrab;
_configProvider.GrowlNotifyOnDownload = data.GrowlNotifyOnDownload;
_configProvider.GrowlHost = data.GrowlHost;
_configProvider.GrowlPassword = data.GrowlPassword;
2011-11-03 05:01:44 +01:00
//Prowl
var prowlSettings = _externalNotificationProvider.GetSettings(typeof(Prowl));
prowlSettings.Enable = data.ProwlEnabled;
_externalNotificationProvider.SaveSettings(prowlSettings);
_configProvider.ProwlNotifyOnGrab = data.ProwlNotifyOnGrab;
_configProvider.ProwlNotifyOnDownload = data.ProwlNotifyOnDownload;
_configProvider.ProwlApiKeys = data.ProwlApiKeys;
_configProvider.ProwlPriority = data.ProwlPriority;
2011-08-08 23:50:48 +02:00
return GetSuccessResult();
}
2011-08-08 23:50:48 +02:00
return GetInvalidModelResult();
}
[HttpPost]
2011-08-22 03:00:12 +02:00
public JsonResult SaveEpisodeSorting(EpisodeSortingModel data)
{
if (ModelState.IsValid)
{
2011-07-08 05:36:02 +02:00
_configProvider.SortingIncludeSeriesName = data.SeriesName;
2011-07-08 05:57:44 +02:00
_configProvider.SortingIncludeEpisodeTitle = data.EpisodeName;
2011-07-08 05:36:02 +02:00
_configProvider.SortingReplaceSpaces = data.ReplaceSpaces;
_configProvider.SortingAppendQuality = data.AppendQuality;
_configProvider.UseSeasonFolder = data.SeasonFolders;
2011-07-08 05:36:02 +02:00
_configProvider.SortingSeasonFolderFormat = data.SeasonFolderFormat;
_configProvider.SortingSeparatorStyle = data.SeparatorStyle;
_configProvider.SortingNumberStyle = data.NumberStyle;
_configProvider.SortingMultiEpisodeStyle = data.MultiEpisodeStyle;
2011-08-08 23:50:48 +02:00
return GetSuccessResult();
}
2011-08-08 23:50:48 +02:00
return GetInvalidModelResult();
}
[HttpPost]
public JsonResult SaveSystem(SystemSettingsModel data)
{
if (ModelState.IsValid)
{
_configFileProvider.Port = data.Port;
_configFileProvider.LaunchBrowser = data.LaunchBrowser;
_configFileProvider.AuthenticationType = data.AuthenticationType;
return GetSuccessResult();
}
return GetInvalidModelResult();
}
2011-08-08 23:50:48 +02:00
private JsonResult GetSuccessResult()
{
return Json(new NotificationResult() { Title = "Settings Saved" });
}
private JsonResult GetInvalidModelResult()
{
return Json(new NotificationResult() { Title = "Unable to save setting", Text = "Invalid post data", NotificationType = NotificationType.Error });
}
2011-11-03 03:44:22 +01:00
private SelectList GetProwlPrioritySelectList()
{
var list = new List<ProwlPrioritySelectListModel>();
list.Add(new ProwlPrioritySelectListModel{ Name = "Very Low", Value = -2 });
list.Add(new ProwlPrioritySelectListModel { Name = "Moderate", Value = -1 });
list.Add(new ProwlPrioritySelectListModel { Name = "Normal", Value = 0 });
list.Add(new ProwlPrioritySelectListModel { Name = "High", Value = 1 });
list.Add(new ProwlPrioritySelectListModel { Name = "Emergency", Value = 2 });
return new SelectList(list, "Value", "Name");
}
2010-09-23 05:19:47 +02:00
}
2011-04-10 04:44:01 +02:00
}