Sonarr/NzbDrone.Core/Repository/Quality/QualityProfile.cs

59 lines
1.8 KiB
C#
Raw Normal View History

2010-09-29 17:19:18 +00:00
using System;
using System.Collections.Generic;
2010-09-30 06:59:00 +00:00
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
2011-06-17 20:31:25 +00:00
using PetaPoco;
2010-09-29 17:19:18 +00:00
namespace NzbDrone.Core.Repository.Quality
2010-09-29 17:19:18 +00:00
{
2011-06-17 20:31:25 +00:00
[TableName("QualityProfiles")]
[PrimaryKey("QualityProfileId", autoIncrement = true)]
2010-09-29 17:19:18 +00:00
public class QualityProfile
{
public virtual int QualityProfileId { get; set; }
[Required(ErrorMessage = "A Name is Required")]
[DisplayName("Name")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string Name { get; set; }
2011-04-10 02:44:01 +00:00
2011-06-17 20:31:25 +00:00
[Ignore]
[DisplayName("Allowed Qualities")]
public List<QualityTypes> Allowed { get; set; }
2011-06-17 20:31:25 +00:00
[Ignore]
[DisplayName("Allowed Qualities String")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string AllowedString { get; set; }
[DisplayName("Cut-off")]
[Required(ErrorMessage = "Valid Cut-off is Required")]
2011-02-03 20:09:19 +00:00
public QualityTypes Cutoff { get; set; }
2010-09-30 06:59:00 +00:00
2011-02-03 20:09:19 +00:00
[EditorBrowsable(EditorBrowsableState.Never)]
public string SonicAllowed
{
get
{
string result = String.Empty;
2011-04-05 05:30:13 +00:00
if (Allowed == null) return result;
2011-04-10 02:44:01 +00:00
2011-02-03 20:09:19 +00:00
foreach (var q in Allowed)
{
2011-04-20 01:56:02 +00:00
result += (int)q + "|";
2011-02-03 20:09:19 +00:00
}
return result.Trim('|');
}
private set
{
var qualities = value.Split('|');
Allowed = new List<QualityTypes>(qualities.Length);
foreach (var quality in qualities.Where(q => !String.IsNullOrWhiteSpace(q)))
2011-02-03 20:09:19 +00:00
{
2011-04-20 01:56:02 +00:00
Allowed.Add((QualityTypes)Convert.ToInt32(quality));
2011-02-03 20:09:19 +00:00
}
}
}
2010-09-29 17:19:18 +00:00
}
2011-04-10 02:44:01 +00:00
}