mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
Quality config complete (needs to look better, but it is functional, minus deleting).
This commit is contained in:
parent
6d790f8939
commit
2ba6057ec7
6 changed files with 80 additions and 20 deletions
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using NzbDrone.Web.Models;
|
||||
|
||||
namespace NzbDrone.Web.Controllers
|
||||
{
|
||||
|
@ -20,5 +21,18 @@ namespace NzbDrone.Web.Controllers
|
|||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult Test()
|
||||
{
|
||||
var model = new TestModel();
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Test(TestModel model)
|
||||
{
|
||||
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,16 @@ namespace NzbDrone.Web.Controllers
|
|||
|
||||
public ViewResult AddUserProfile()
|
||||
{
|
||||
return View("UserProfileSection", new QualityProfile());
|
||||
var qualityTypes = new List<QualityTypes>();
|
||||
|
||||
foreach (QualityTypes qual in Enum.GetValues(typeof(QualityTypes)))
|
||||
{
|
||||
qualityTypes.Add(qual);
|
||||
}
|
||||
|
||||
ViewData["Qualities"] = qualityTypes;
|
||||
|
||||
return View("UserProfileSection", new QualityProfile { Name = "New Profile", UserProfile = true });
|
||||
}
|
||||
|
||||
public ActionResult SubMenu()
|
||||
|
@ -290,6 +299,27 @@ namespace NzbDrone.Web.Controllers
|
|||
try
|
||||
{
|
||||
_configProvider.SetValue("DefaultQualityProfile", data.DefaultProfileId.ToString());
|
||||
|
||||
foreach (var profile in data.UserProfiles)
|
||||
{
|
||||
profile.Allowed = new List<QualityTypes>();
|
||||
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))
|
||||
profile.Cutoff = profile.Allowed.Last();
|
||||
|
||||
if (profile.ProfileId > 0)
|
||||
_qualityProvider.Update(profile);
|
||||
|
||||
else
|
||||
_qualityProvider.Add(profile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue