diff --git a/NzbDrone.Core/Repository/Quality/QualityProfile.cs b/NzbDrone.Core/Repository/Quality/QualityProfile.cs index 2ddfc0cc0..c3a08de56 100644 --- a/NzbDrone.Core/Repository/Quality/QualityProfile.cs +++ b/NzbDrone.Core/Repository/Quality/QualityProfile.cs @@ -11,6 +11,7 @@ namespace NzbDrone.Core.Repository.Quality [SubSonicPrimaryKey(true)] public int ProfileId { get; set; } + [Required (ErrorMessage = "A Name is Required")] [DisplayName("Name")] public string Name { get; set; } public bool UserProfile { get; set; } //Allows us to tell the difference between default and user profiles diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 67022fce0..d5a30a658 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -304,36 +304,38 @@ namespace NzbDrone.Web.Controllers { try { - _configProvider.SetValue("DefaultQualityProfile", data.DefaultProfileId.ToString()); - - foreach (var dbProfile in _qualityProvider.GetAllProfiles().Where(q => q.UserProfile)) + if (ModelState.IsValid) { - if (!data.UserProfiles.Exists(p => p.ProfileId == dbProfile.ProfileId)) - _qualityProvider.Delete(dbProfile.ProfileId); - } + _configProvider.SetValue("DefaultQualityProfile", data.DefaultProfileId.ToString()); - - foreach (var profile in data.UserProfiles) - { - Logger.Debug(String.Format("Updating User Profile: {0}", profile)); - - profile.Allowed = new List(); - foreach (var quality in profile.AllowedString.Split(',')) + foreach (var dbProfile in _qualityProvider.GetAllProfiles().Where(q => q.UserProfile)) { - var qType = (QualityTypes)Enum.Parse(typeof(QualityTypes), quality); - profile.Allowed.Add(qType); + if (!data.UserProfiles.Exists(p => p.ProfileId == dbProfile.ProfileId)) + _qualityProvider.Delete(dbProfile.ProfileId); } - //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)) - throw new InvalidOperationException("Invalid Cutoff Value"); - //profile.Cutoff = profile.Allowed.Last(); + foreach (var profile in data.UserProfiles) + { + Logger.Debug(String.Format("Updating User Profile: {0}", profile)); - if (profile.ProfileId > 0) - _qualityProvider.Update(profile); + profile.Allowed = new List(); + foreach (var quality in profile.AllowedString.Split(',')) + { + var qType = (QualityTypes) Enum.Parse(typeof (QualityTypes), quality); + profile.Allowed.Add(qType); + } - else - _qualityProvider.Add(profile); + //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)) + throw new InvalidOperationException("Invalid Cutoff Value"); + //profile.Cutoff = profile.Allowed.Last(); + + if (profile.ProfileId > 0) + _qualityProvider.Update(profile); + + else + _qualityProvider.Add(profile); + } } } diff --git a/NzbDrone.Web/Models/QualityModel.cs b/NzbDrone.Web/Models/QualityModel.cs index 58f9b7951..284b34b88 100644 --- a/NzbDrone.Web/Models/QualityModel.cs +++ b/NzbDrone.Web/Models/QualityModel.cs @@ -13,7 +13,6 @@ namespace NzbDrone.Web.Models { public List Profiles { get; set; } public List UserProfiles { get; set; } - //public List Qualities { get; set; } [DisplayName("Default Quality Profile")] public int DefaultProfileId { get; set; } diff --git a/NzbDrone.Web/Views/Settings/Downloads.ascx b/NzbDrone.Web/Views/Settings/Downloads.ascx index c1524fbb7..2a4ee2e42 100644 --- a/NzbDrone.Web/Views/Settings/Downloads.ascx +++ b/NzbDrone.Web/Views/Settings/Downloads.ascx @@ -23,8 +23,6 @@ } - - <% Html.EnableClientValidation(); %> <% using (Html.BeginForm("SaveDownloads", "Settings", FormMethod.Post, new { id = "form", name = "form" })) diff --git a/NzbDrone.Web/Views/Settings/Quality.ascx b/NzbDrone.Web/Views/Settings/Quality.ascx index 4f946eb60..4f7df6f7a 100644 --- a/NzbDrone.Web/Views/Settings/Quality.ascx +++ b/NzbDrone.Web/Views/Settings/Quality.ascx @@ -26,11 +26,13 @@ + <% Html.EnableClientValidation(); %> + <% using (Html.BeginForm("SaveQuality", "Settings", FormMethod.Post, new { id = "form", name = "form" })) {%>
Quality - <%: Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") %> + <%--<%: Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") %>--%>