Quality config complete (needs to look better, but it is functional, minus deleting).

This commit is contained in:
markus101 2011-02-05 23:13:17 -08:00
parent 6d790f8939
commit 2ba6057ec7
6 changed files with 80 additions and 20 deletions

View file

@ -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)