2010-09-23 06:19:47 +03:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Web.Mvc;
|
2011-01-29 08:10:22 +02:00
|
|
|
using NLog;
|
2011-03-03 10:50:33 +02:00
|
|
|
using NzbDrone.Core.Helpers;
|
2011-02-11 03:22:29 +02:00
|
|
|
using NzbDrone.Core.Model;
|
2011-02-05 08:07:25 +02:00
|
|
|
using NzbDrone.Core.Providers;
|
2011-04-04 06:50:12 +03:00
|
|
|
using NzbDrone.Core.Providers.Core;
|
2011-03-09 09:40:48 +02:00
|
|
|
using NzbDrone.Core.Repository;
|
2011-02-05 08:07:25 +02:00
|
|
|
using NzbDrone.Core.Repository.Quality;
|
2010-09-24 08:21:45 +03:00
|
|
|
using NzbDrone.Web.Models;
|
2010-09-23 06:19:47 +03:00
|
|
|
|
|
|
|
namespace NzbDrone.Web.Controllers
|
|
|
|
{
|
2010-10-08 06:35:04 +03:00
|
|
|
[HandleError]
|
2010-09-23 06:19:47 +03:00
|
|
|
public class SettingsController : Controller
|
|
|
|
{
|
2011-03-29 00:57:06 +03:00
|
|
|
private const string SETTINGS_SAVED = "Settings Saved.";
|
|
|
|
private const string SETTINGS_FAILED = "Error Saving Settings, please fix any errors";
|
2011-04-10 05:44:01 +03:00
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
private readonly ConfigProvider _configProvider;
|
|
|
|
private readonly IndexerProvider _indexerProvider;
|
|
|
|
private readonly QualityProvider _qualityProvider;
|
|
|
|
private readonly RootDirProvider _rootDirProvider;
|
2010-09-24 08:21:45 +03:00
|
|
|
|
2011-04-10 04:34:36 +03:00
|
|
|
public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider,
|
2011-04-10 05:44:01 +03:00
|
|
|
QualityProvider qualityProvider, RootDirProvider rootDirProvider)
|
2010-09-24 08:21:45 +03:00
|
|
|
{
|
2010-09-28 07:25:41 +03:00
|
|
|
_configProvider = configProvider;
|
2011-01-29 08:10:22 +02:00
|
|
|
_indexerProvider = indexerProvider;
|
2011-02-03 04:49:52 +02:00
|
|
|
_qualityProvider = qualityProvider;
|
2011-03-09 09:40:48 +02:00
|
|
|
_rootDirProvider = rootDirProvider;
|
2010-09-24 08:21:45 +03:00
|
|
|
}
|
2010-09-23 06:19:47 +03:00
|
|
|
|
2011-01-29 08:10:22 +02:00
|
|
|
public ActionResult Index(string viewName)
|
2010-09-23 06:19:47 +03:00
|
|
|
{
|
2011-01-29 08:10:22 +02:00
|
|
|
if (viewName != null)
|
|
|
|
ViewData["viewName"] = viewName;
|
|
|
|
|
|
|
|
else
|
2011-03-09 09:40:48 +02:00
|
|
|
return RedirectToAction("General");
|
2011-01-29 08:10:22 +02:00
|
|
|
|
2011-03-09 09:40:48 +02:00
|
|
|
return View("Index");
|
2011-01-29 08:10:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public ActionResult General()
|
|
|
|
{
|
|
|
|
ViewData["viewName"] = "General";
|
2011-03-29 00:57:06 +03:00
|
|
|
|
2011-01-29 08:10:22 +02:00
|
|
|
return View("Index", new SettingsModel
|
|
|
|
{
|
2011-03-29 00:57:06 +03:00
|
|
|
Directories = _rootDirProvider.GetAll()
|
2011-01-29 08:10:22 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public ActionResult Indexers()
|
|
|
|
{
|
|
|
|
ViewData["viewName"] = "Indexers";
|
2011-02-11 03:22:29 +02:00
|
|
|
return View("Index", new IndexerSettingsModel
|
2011-01-29 08:10:22 +02:00
|
|
|
{
|
2011-04-10 05:44:01 +03:00
|
|
|
NzbMatrixUsername =
|
|
|
|
_configProvider.GetValue("NzbMatrixUsername", String.Empty, true),
|
|
|
|
NzbMatrixApiKey =
|
|
|
|
_configProvider.GetValue("NzbMatrixApiKey", String.Empty, true),
|
2011-03-07 00:27:52 +02:00
|
|
|
NzbsOrgUId = _configProvider.GetValue("NzbsOrgUId", String.Empty, true),
|
|
|
|
NzbsOrgHash = _configProvider.GetValue("NzbsOrgHash", String.Empty, true),
|
|
|
|
NzbsrusUId = _configProvider.GetValue("NzbsrusUId", String.Empty, true),
|
|
|
|
NzbsrusHash = _configProvider.GetValue("NzbsrusHash", String.Empty, true),
|
2011-01-29 08:10:22 +02:00
|
|
|
Indexers = _indexerProvider.AllIndexers()
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public ActionResult Downloads()
|
|
|
|
{
|
|
|
|
ViewData["viewName"] = "Downloads";
|
2011-02-11 03:22:29 +02:00
|
|
|
|
|
|
|
var model = new DownloadSettingsModel
|
|
|
|
{
|
|
|
|
SyncFrequency = Convert.ToInt32(_configProvider.GetValue("SyncFrequency", "15", true)),
|
2011-04-10 05:44:01 +03:00
|
|
|
DownloadPropers =
|
|
|
|
Convert.ToBoolean(_configProvider.GetValue("DownloadPropers", "false", true)),
|
2011-02-11 03:22:29 +02:00
|
|
|
Retention = Convert.ToInt32(_configProvider.GetValue("Retention", "500", true)),
|
2011-03-07 00:27:52 +02:00
|
|
|
SabHost = _configProvider.GetValue("SabHost", "localhost", true),
|
2011-02-11 03:22:29 +02:00
|
|
|
SabPort = Convert.ToInt32(_configProvider.GetValue("SabPort", "8080", true)),
|
2011-03-07 00:27:52 +02:00
|
|
|
SabApiKey = _configProvider.GetValue("SabApiKey", String.Empty, true),
|
|
|
|
SabUsername = _configProvider.GetValue("SabUsername", String.Empty, true),
|
|
|
|
SabPassword = _configProvider.GetValue("SabPassword", String.Empty, true),
|
|
|
|
SabTvCategory = _configProvider.GetValue("SabTvCategory", String.Empty, true),
|
2011-04-10 05:44:01 +03:00
|
|
|
SabTvPriority =
|
|
|
|
(SabnzbdPriorityType)
|
|
|
|
Enum.Parse(typeof (SabnzbdPriorityType),
|
|
|
|
_configProvider.GetValue("SabTvPriority", "Normal", true)),
|
2011-03-22 05:51:03 +02:00
|
|
|
UseBlackHole = Convert.ToBoolean(_configProvider.GetValue("UseBlackHole", true, true)),
|
|
|
|
BlackholeDirectory = _configProvider.GetValue("BlackholeDirectory", String.Empty, true)
|
2011-02-11 03:22:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
return View("Index", model);
|
2011-01-29 08:10:22 +02:00
|
|
|
}
|
|
|
|
|
2011-02-03 04:49:52 +02:00
|
|
|
public ActionResult Quality()
|
|
|
|
{
|
2011-02-03 20:28:14 +02:00
|
|
|
ViewData["viewName"] = "Quality";
|
2011-02-03 04:49:52 +02:00
|
|
|
|
2011-02-05 08:07:25 +02:00
|
|
|
var qualityTypes = new List<QualityTypes>();
|
2011-02-03 04:49:52 +02:00
|
|
|
|
2011-04-10 05:44:01 +03:00
|
|
|
foreach (QualityTypes qual in Enum.GetValues(typeof (QualityTypes)))
|
2011-02-05 08:07:25 +02:00
|
|
|
{
|
|
|
|
qualityTypes.Add(qual);
|
|
|
|
}
|
|
|
|
|
2011-02-06 04:52:49 +02:00
|
|
|
ViewData["Qualities"] = qualityTypes;
|
|
|
|
|
|
|
|
var userProfiles = _qualityProvider.GetAllProfiles().Where(q => q.UserProfile).ToList();
|
|
|
|
var profiles = _qualityProvider.GetAllProfiles().ToList();
|
2011-02-11 03:22:29 +02:00
|
|
|
|
2011-04-10 05:44:01 +03:00
|
|
|
var defaultQualityQualityProfileId =
|
|
|
|
Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId, true));
|
2011-02-05 08:07:25 +02:00
|
|
|
|
2011-02-17 19:45:02 +02:00
|
|
|
var selectList = new SelectList(profiles, "QualityProfileId", "Name");
|
2011-02-05 08:07:25 +02:00
|
|
|
|
|
|
|
var model = new QualityModel
|
2011-04-10 05:44:01 +03:00
|
|
|
{
|
|
|
|
Profiles = profiles,
|
|
|
|
UserProfiles = userProfiles,
|
|
|
|
DefaultQualityProfileId = defaultQualityQualityProfileId,
|
|
|
|
SelectList = selectList
|
|
|
|
};
|
2011-02-03 04:49:52 +02:00
|
|
|
|
|
|
|
return View("Index", model);
|
|
|
|
}
|
|
|
|
|
2011-03-07 09:32:36 +02:00
|
|
|
public ActionResult Notifications()
|
|
|
|
{
|
|
|
|
ViewData["viewName"] = "Notifications";
|
|
|
|
|
|
|
|
var model = new NotificationSettingsModel
|
2011-04-10 05:44:01 +03:00
|
|
|
{
|
|
|
|
XbmcEnabled = Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false, true)),
|
|
|
|
XbmcNotifyOnGrab =
|
|
|
|
Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false, true)),
|
|
|
|
XbmcNotifyOnDownload =
|
|
|
|
Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false, true)),
|
|
|
|
XbmcNotifyOnRename =
|
|
|
|
Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false, true)),
|
|
|
|
XbmcNotificationImage =
|
|
|
|
Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false, true)),
|
|
|
|
XbmcDisplayTime = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", 3, true)),
|
|
|
|
XbmcUpdateOnDownload =
|
|
|
|
Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload ", false, true)),
|
|
|
|
XbmcUpdateOnRename =
|
|
|
|
Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false, true)),
|
|
|
|
XbmcFullUpdate =
|
|
|
|
Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true)),
|
|
|
|
XbmcCleanOnDownload =
|
|
|
|
Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false, true)),
|
|
|
|
XbmcCleanOnRename =
|
|
|
|
Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false, true)),
|
|
|
|
XbmcHosts = _configProvider.GetValue("XbmcHosts", "localhost:80", true),
|
|
|
|
XbmcUsername = _configProvider.GetValue("XbmcUsername", String.Empty, true),
|
|
|
|
XbmcPassword = _configProvider.GetValue("XbmcPassword", String.Empty, true)
|
|
|
|
};
|
2011-03-07 09:32:36 +02:00
|
|
|
|
|
|
|
return View("Index", model);
|
|
|
|
}
|
|
|
|
|
2011-02-26 06:07:22 +02:00
|
|
|
public ActionResult EpisodeSorting()
|
|
|
|
{
|
|
|
|
ViewData["viewName"] = "EpisodeSorting";
|
|
|
|
|
|
|
|
var model = new EpisodeSortingModel();
|
|
|
|
|
|
|
|
model.ShowName = Convert.ToBoolean(_configProvider.GetValue("Sorting_ShowName", true, true));
|
|
|
|
model.EpisodeName = Convert.ToBoolean(_configProvider.GetValue("Sorting_EpisodeName", true, true));
|
|
|
|
model.ReplaceSpaces = Convert.ToBoolean(_configProvider.GetValue("Sorting_ReplaceSpaces", false, true));
|
|
|
|
model.AppendQuality = Convert.ToBoolean(_configProvider.GetValue("Sorting_AppendQuality", false, true));
|
|
|
|
model.UseAirByDate = Convert.ToBoolean(_configProvider.GetValue("Sorting_UseAirByDate", true, true));
|
2011-04-01 09:36:34 +03:00
|
|
|
model.SeasonFolders = _configProvider.UseSeasonFolder;
|
2011-02-26 06:07:22 +02:00
|
|
|
model.SeasonFolderFormat = _configProvider.GetValue("Sorting_SeasonFolderFormat", "Season %s", true);
|
|
|
|
model.SeparatorStyle = Convert.ToInt32(_configProvider.GetValue("Sorting_SeparatorStyle", 0, true));
|
|
|
|
model.NumberStyle = Convert.ToInt32(_configProvider.GetValue("Sorting_NumberStyle", 2, true));
|
|
|
|
model.MultiEpisodeStyle = Convert.ToInt32(_configProvider.GetValue("Sorting_MultiEpisodeStyle", 0, true));
|
|
|
|
|
|
|
|
model.SeparatorStyles = new SelectList(EpisodeSortingHelper.GetSeparatorStyles(), "Id", "Name");
|
|
|
|
model.NumberStyles = new SelectList(EpisodeSortingHelper.GetNumberStyles(), "Id", "Name");
|
|
|
|
model.MultiEpisodeStyles = new SelectList(EpisodeSortingHelper.GetMultiEpisodeStyles(), "Id", "Name");
|
|
|
|
|
|
|
|
return View("Index", model);
|
|
|
|
}
|
|
|
|
|
2011-02-05 20:27:14 +02:00
|
|
|
public ViewResult AddUserProfile()
|
|
|
|
{
|
2011-02-06 09:13:17 +02:00
|
|
|
var qualityTypes = new List<QualityTypes>();
|
|
|
|
|
2011-04-10 05:44:01 +03:00
|
|
|
foreach (QualityTypes qual in Enum.GetValues(typeof (QualityTypes)))
|
2011-02-06 09:13:17 +02:00
|
|
|
{
|
|
|
|
qualityTypes.Add(qual);
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewData["Qualities"] = qualityTypes;
|
|
|
|
|
2011-04-10 05:44:01 +03:00
|
|
|
return View("UserProfileSection", new QualityProfile {Name = "New Profile", UserProfile = true});
|
2011-02-05 20:27:14 +02:00
|
|
|
}
|
|
|
|
|
2011-03-09 09:40:48 +02:00
|
|
|
public ViewResult AddRootDir()
|
|
|
|
{
|
2011-03-29 02:38:05 +03:00
|
|
|
return View("RootDir", new RootDir());
|
2011-03-09 09:40:48 +02:00
|
|
|
}
|
|
|
|
|
2011-01-29 08:10:22 +02:00
|
|
|
public ActionResult SubMenu()
|
|
|
|
{
|
|
|
|
return PartialView();
|
|
|
|
}
|
|
|
|
|
2011-02-12 08:10:38 +02:00
|
|
|
public QualityModel GetUpdatedProfileList()
|
|
|
|
{
|
|
|
|
var profiles = _qualityProvider.GetAllProfiles().ToList();
|
2011-04-10 05:44:01 +03:00
|
|
|
var defaultQualityQualityProfileId =
|
|
|
|
Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId, true));
|
2011-02-17 19:45:02 +02:00
|
|
|
var selectList = new SelectList(profiles, "QualityProfileId", "Name");
|
2011-02-16 06:44:19 +02:00
|
|
|
|
2011-04-10 05:44:01 +03:00
|
|
|
return new QualityModel {DefaultQualityProfileId = defaultQualityQualityProfileId, SelectList = selectList};
|
2011-02-12 08:10:38 +02:00
|
|
|
}
|
|
|
|
|
2011-01-29 08:10:22 +02:00
|
|
|
[HttpPost]
|
|
|
|
public ActionResult SaveGeneral(SettingsModel data)
|
|
|
|
{
|
2011-03-29 00:57:06 +03:00
|
|
|
if (data.Directories != null && data.Directories.Count > 0)
|
2011-01-29 08:10:22 +02:00
|
|
|
{
|
2011-03-09 09:40:48 +02:00
|
|
|
//If the Javascript was beaten we need to return an error
|
2011-03-29 00:57:06 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Kay.one: I can't see what its doing, all it does it dooesn't let me s.
|
|
|
|
* if (!data.Directories.Exists(d => d.Default))
|
|
|
|
return Content(SETTINGS_FAILED);*/
|
2011-03-09 09:40:48 +02:00
|
|
|
|
|
|
|
var currentRootDirs = _rootDirProvider.GetAll();
|
|
|
|
|
|
|
|
foreach (var currentRootDir in currentRootDirs)
|
|
|
|
{
|
|
|
|
var closureRootDir = currentRootDir;
|
2011-03-29 02:38:05 +03:00
|
|
|
if (!data.Directories.Exists(d => d.Id == closureRootDir.Id))
|
|
|
|
_rootDirProvider.Remove(closureRootDir.Id);
|
2011-03-09 09:40:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach (var dir in data.Directories)
|
|
|
|
{
|
2011-03-29 02:38:05 +03:00
|
|
|
if (dir.Id == 0)
|
2011-03-09 09:40:48 +02:00
|
|
|
_rootDirProvider.Add(dir);
|
|
|
|
|
|
|
|
else
|
|
|
|
_rootDirProvider.Update(dir);
|
|
|
|
}
|
|
|
|
|
2011-03-29 00:57:06 +03:00
|
|
|
return Content(SETTINGS_SAVED);
|
2011-01-29 08:10:22 +02:00
|
|
|
}
|
2011-02-11 03:22:29 +02:00
|
|
|
|
2011-03-29 00:57:06 +03:00
|
|
|
return Content(SETTINGS_FAILED);
|
2010-09-24 08:21:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
[HttpPost]
|
2011-02-11 03:22:29 +02:00
|
|
|
public ActionResult SaveIndexers(IndexerSettingsModel data)
|
2010-09-24 08:21:45 +03:00
|
|
|
{
|
2011-02-15 03:20:17 +02:00
|
|
|
if (ModelState.IsValid)
|
2010-09-24 08:21:45 +03:00
|
|
|
{
|
2011-01-31 03:30:59 +02:00
|
|
|
//Todo: Only allow indexers to be enabled if user information has been provided
|
2011-01-29 08:10:22 +02:00
|
|
|
foreach (var indexer in data.Indexers)
|
|
|
|
_indexerProvider.Update(indexer);
|
|
|
|
|
2011-03-31 04:42:27 +03:00
|
|
|
_configProvider.NzbMatrixUsername = data.NzbMatrixUsername;
|
|
|
|
_configProvider.NzbMatrixApiKey = data.NzbMatrixApiKey;
|
|
|
|
_configProvider.NzbsOrgUId = data.NzbsOrgUId;
|
|
|
|
_configProvider.NzbsOrgHash = data.NzbsOrgHash;
|
|
|
|
_configProvider.NzbsrusUId = data.NzbsrusUId;
|
|
|
|
_configProvider.NzbsrusHash = data.NzbsrusHash;
|
2011-01-31 03:30:59 +02:00
|
|
|
|
2011-03-29 00:57:06 +03:00
|
|
|
return Content(SETTINGS_SAVED);
|
2011-01-29 08:10:22 +02:00
|
|
|
}
|
|
|
|
|
2011-03-29 00:57:06 +03:00
|
|
|
return Content(SETTINGS_FAILED);
|
2010-09-23 06:19:47 +03:00
|
|
|
}
|
|
|
|
|
2011-01-29 08:10:22 +02:00
|
|
|
[HttpPost]
|
2011-02-11 03:22:29 +02:00
|
|
|
public ActionResult SaveDownloads(DownloadSettingsModel data)
|
2011-01-29 08:10:22 +02:00
|
|
|
{
|
2011-02-11 03:22:29 +02:00
|
|
|
if (ModelState.IsValid)
|
2011-01-29 08:10:22 +02:00
|
|
|
{
|
2011-03-31 04:42:27 +03:00
|
|
|
_configProvider.SyncFrequency = data.SyncFrequency.ToString();
|
|
|
|
_configProvider.DownloadPropers = data.DownloadPropers.ToString();
|
|
|
|
_configProvider.Retention = data.Retention.ToString();
|
|
|
|
_configProvider.SabHost = data.SabHost;
|
|
|
|
_configProvider.SabPort = data.SabPort.ToString();
|
|
|
|
_configProvider.SabApiKey = data.SabApiKey;
|
|
|
|
_configProvider.SabPassword = data.SabPassword;
|
|
|
|
_configProvider.SabTvCategory = data.SabTvCategory;
|
|
|
|
_configProvider.SabUsername = data.SabUsername;
|
|
|
|
_configProvider.SabTvPriority = data.SabTvPriority.ToString();
|
|
|
|
_configProvider.UseBlackhole = data.UseBlackHole.ToString();
|
|
|
|
_configProvider.BlackholeDirectory = data.BlackholeDirectory;
|
2011-01-29 08:10:22 +02:00
|
|
|
|
2011-03-29 00:57:06 +03:00
|
|
|
return Content(SETTINGS_SAVED);
|
2011-02-11 03:22:29 +02:00
|
|
|
}
|
|
|
|
|
2011-03-29 00:57:06 +03:00
|
|
|
return Content(SETTINGS_FAILED);
|
2011-01-29 08:10:22 +02:00
|
|
|
}
|
|
|
|
|
2011-02-04 04:58:02 +02:00
|
|
|
[HttpPost]
|
|
|
|
public ActionResult SaveQuality(QualityModel data)
|
|
|
|
{
|
2011-02-15 03:20:17 +02:00
|
|
|
if (ModelState.IsValid)
|
2011-02-04 04:58:02 +02:00
|
|
|
{
|
2011-02-17 19:45:02 +02:00
|
|
|
_configProvider.SetValue("DefaultQualityProfile", data.DefaultQualityProfileId.ToString());
|
2011-02-15 03:20:17 +02:00
|
|
|
|
|
|
|
//Saves only the Default Quality, skips User Profiles since none exist
|
|
|
|
if (data.UserProfiles == null)
|
2011-03-29 00:57:06 +03:00
|
|
|
return Content(SETTINGS_SAVED);
|
2011-02-15 03:20:17 +02:00
|
|
|
|
|
|
|
foreach (var dbProfile in _qualityProvider.GetAllProfiles().Where(q => q.UserProfile))
|
2011-02-06 09:13:17 +02:00
|
|
|
{
|
2011-02-17 19:45:02 +02:00
|
|
|
if (!data.UserProfiles.Exists(p => p.QualityProfileId == dbProfile.QualityProfileId))
|
|
|
|
_qualityProvider.Delete(dbProfile.QualityProfileId);
|
2011-02-15 03:20:17 +02:00
|
|
|
}
|
2011-02-07 23:22:45 +02:00
|
|
|
|
2011-02-15 03:20:17 +02:00
|
|
|
foreach (var profile in data.UserProfiles)
|
|
|
|
{
|
|
|
|
Logger.Debug(String.Format("Updating User Profile: {0}", profile));
|
2011-02-06 09:13:17 +02:00
|
|
|
|
2011-02-15 03:20:17 +02:00
|
|
|
profile.Allowed = new List<QualityTypes>();
|
|
|
|
foreach (var quality in profile.AllowedString.Split(','))
|
2011-02-15 02:45:31 +02:00
|
|
|
{
|
2011-04-10 05:44:01 +03:00
|
|
|
var qType = (QualityTypes) Enum.Parse(typeof (QualityTypes), quality);
|
2011-02-15 03:20:17 +02:00
|
|
|
profile.Allowed.Add(qType);
|
|
|
|
}
|
2011-02-15 02:45:31 +02:00
|
|
|
|
2011-02-15 03:20:17 +02:00
|
|
|
//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))
|
|
|
|
return Content("Error Saving Settings, please fix any errors");
|
|
|
|
//profile.Cutoff = profile.Allowed.Last();
|
2011-02-06 09:13:17 +02:00
|
|
|
|
2011-02-17 19:45:02 +02:00
|
|
|
if (profile.QualityProfileId > 0)
|
2011-02-15 03:20:17 +02:00
|
|
|
_qualityProvider.Update(profile);
|
2011-02-06 09:13:17 +02:00
|
|
|
|
2011-02-15 03:20:17 +02:00
|
|
|
else
|
|
|
|
_qualityProvider.Add(profile);
|
2011-02-15 02:45:31 +02:00
|
|
|
|
2011-03-29 00:57:06 +03:00
|
|
|
return Content(SETTINGS_SAVED);
|
2011-02-06 09:13:17 +02:00
|
|
|
}
|
2011-02-04 04:58:02 +02:00
|
|
|
}
|
2011-02-05 08:07:25 +02:00
|
|
|
|
2011-03-29 00:57:06 +03:00
|
|
|
return Content(SETTINGS_FAILED);
|
2011-02-11 03:22:29 +02:00
|
|
|
}
|
2011-02-26 06:07:22 +02:00
|
|
|
|
2011-03-07 09:32:36 +02:00
|
|
|
[HttpPost]
|
|
|
|
public ActionResult SaveNotifications(NotificationSettingsModel data)
|
|
|
|
{
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
{
|
|
|
|
_configProvider.SetValue("XbmcEnabled", data.XbmcEnabled.ToString());
|
|
|
|
_configProvider.SetValue("XbmcNotifyOnGrab", data.XbmcNotifyOnGrab.ToString());
|
|
|
|
_configProvider.SetValue("XbmcNotifyOnDownload", data.XbmcNotifyOnDownload.ToString());
|
|
|
|
_configProvider.SetValue("XbmcNotifyOnRename", data.XbmcNotifyOnRename.ToString());
|
|
|
|
_configProvider.SetValue("XbmcNotificationImage", data.XbmcNotificationImage.ToString());
|
|
|
|
_configProvider.SetValue("XbmcDisplayTime", data.XbmcDisplayTime.ToString());
|
|
|
|
_configProvider.SetValue("XbmcUpdateOnDownload", data.XbmcUpdateOnDownload.ToString());
|
|
|
|
_configProvider.SetValue("XbmcUpdateOnRename", data.XbmcUpdateOnRename.ToString());
|
|
|
|
_configProvider.SetValue("XbmcFullUpdate", data.XbmcFullUpdate.ToString());
|
|
|
|
_configProvider.SetValue("XbmcCleanOnDownload", data.XbmcCleanOnDownload.ToString());
|
|
|
|
_configProvider.SetValue("XbmcCleanOnRename", data.XbmcCleanOnRename.ToString());
|
|
|
|
_configProvider.SetValue("XbmcHosts", data.XbmcHosts);
|
|
|
|
_configProvider.SetValue("XbmcUsername", data.XbmcUsername);
|
|
|
|
_configProvider.SetValue("XbmcPassword", data.XbmcPassword);
|
|
|
|
|
2011-03-29 00:57:06 +03:00
|
|
|
return Content(SETTINGS_SAVED);
|
2011-03-07 09:32:36 +02:00
|
|
|
}
|
|
|
|
|
2011-03-29 00:57:06 +03:00
|
|
|
return Content(SETTINGS_FAILED);
|
2011-03-07 09:32:36 +02:00
|
|
|
}
|
|
|
|
|
2011-02-26 06:07:22 +02:00
|
|
|
[HttpPost]
|
|
|
|
public ActionResult SaveEpisodeSorting(EpisodeSortingModel data)
|
|
|
|
{
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
{
|
|
|
|
_configProvider.SetValue("Sorting_ShowName", data.ShowName.ToString());
|
|
|
|
_configProvider.SetValue("Sorting_EpisodeName", data.EpisodeName.ToString());
|
|
|
|
_configProvider.SetValue("Sorting_ReplaceSpaces", data.ReplaceSpaces.ToString());
|
|
|
|
_configProvider.SetValue("Sorting_AppendQuality", data.AppendQuality.ToString());
|
|
|
|
_configProvider.SetValue("Sorting_UseAirByDate", data.UseAirByDate.ToString());
|
|
|
|
_configProvider.SetValue("Sorting_SeasonFolder", data.SeasonFolders.ToString());
|
|
|
|
_configProvider.SetValue("Sorting_SeasonFolderFormat", data.SeasonFolderFormat);
|
|
|
|
_configProvider.SetValue("Sorting_SeparatorStyle", data.SeparatorStyle.ToString());
|
|
|
|
_configProvider.SetValue("Sorting_NumberStyle", data.NumberStyle.ToString());
|
|
|
|
_configProvider.SetValue("Sorting_MultiEpisodeStyle", data.MultiEpisodeStyle.ToString());
|
|
|
|
|
2011-03-29 00:57:06 +03:00
|
|
|
return Content(SETTINGS_SAVED);
|
2011-02-26 06:07:22 +02:00
|
|
|
}
|
|
|
|
|
2011-03-29 00:57:06 +03:00
|
|
|
return Content(SETTINGS_FAILED);
|
2011-02-26 06:07:22 +02:00
|
|
|
}
|
2010-09-23 06:19:47 +03:00
|
|
|
}
|
2011-04-10 05:44:01 +03:00
|
|
|
}
|