diff --git a/NzbDrone.Core.Test/QualityProfileTest.cs b/NzbDrone.Core.Test/QualityProfileTest.cs index 292daedca..f1b04f53c 100644 --- a/NzbDrone.Core.Test/QualityProfileTest.cs +++ b/NzbDrone.Core.Test/QualityProfileTest.cs @@ -40,6 +40,29 @@ namespace NzbDrone.Core.Test Assert.AreEqual(testProfile.Allowed, fetch.Allowed); } + + [Test] + public void Test_Storage_no_allowed() + { + //Arrange + var database = MockLib.GetEmptyDatabase(); + var testProfile = new QualityProfile + { + Name = Guid.NewGuid().ToString(), + Cutoff = QualityTypes.SDTV + }; + + //Act + var id = Convert.ToInt32(database.Insert(testProfile)); + var fetch = database.SingleOrDefault(id); + + //Assert + Assert.AreEqual(id, fetch.QualityProfileId); + Assert.AreEqual(testProfile.Name, fetch.Name); + Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff); + fetch.Allowed.Should().HaveCount(0); + } + [Test] public void Test_Series_Quality() { diff --git a/NzbDrone.Core.Test/SeriesProviderTest.cs b/NzbDrone.Core.Test/SeriesProviderTest.cs index 2387bf0e6..1a24be68f 100644 Binary files a/NzbDrone.Core.Test/SeriesProviderTest.cs and b/NzbDrone.Core.Test/SeriesProviderTest.cs differ diff --git a/NzbDrone.Core/Providers/QualityProvider.cs b/NzbDrone.Core/Providers/QualityProvider.cs index a175acecf..fc9fd5353 100644 --- a/NzbDrone.Core/Providers/QualityProvider.cs +++ b/NzbDrone.Core/Providers/QualityProvider.cs @@ -51,9 +51,9 @@ namespace NzbDrone.Core.Providers return profiles; } - public virtual QualityProfile Find(int profileId) + public virtual QualityProfile Get(int profileId) { - return _database.SingleOrDefault(profileId); + return _database.Single(profileId); } public virtual void SetupDefaultProfiles() diff --git a/NzbDrone.Core/Providers/SeriesProvider.cs b/NzbDrone.Core/Providers/SeriesProvider.cs index f7eec2774..c2c5b02b8 100644 --- a/NzbDrone.Core/Providers/SeriesProvider.cs +++ b/NzbDrone.Core/Providers/SeriesProvider.cs @@ -38,13 +38,18 @@ namespace NzbDrone.Core.Providers public virtual IList GetAllSeries() { var series = _database.Fetch(); - series.ForEach(c => c.QualityProfile = _qualityProvider.Find(c.QualityProfileId)); + series.ForEach(c => c.QualityProfile = _qualityProvider.Get(c.QualityProfileId)); return series; } public virtual Series GetSeries(int seriesId) { - return _database.SingleOrDefault("WHERE seriesId= @0", seriesId); + var series = _database.SingleOrDefault("WHERE seriesId= @0", seriesId); + if (series != null) + { + series.QualityProfile = _qualityProvider.Get(series.QualityProfileId); + } + return series; } /// diff --git a/NzbDrone.Core/Repository/Episode.cs b/NzbDrone.Core/Repository/Episode.cs index 25bfd4464..b8145814f 100644 --- a/NzbDrone.Core/Repository/Episode.cs +++ b/NzbDrone.Core/Repository/Episode.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using NzbDrone.Core.Model; using PetaPoco; @@ -9,30 +8,26 @@ namespace NzbDrone.Core.Repository [PrimaryKey("EpisodeId", autoIncrement = true)] public class Episode { + public int EpisodeId { get; set; } - public virtual int EpisodeId { get; set; } + public int? TvDbEpisodeId { get; set; } - public virtual int? TvDbEpisodeId { get; set; } + public int SeriesId { get; set; } + public int EpisodeFileId { get; set; } + public int SeasonNumber { get; set; } + public int EpisodeNumber { get; set; } + public string Title { get; set; } + public DateTime AirDate { get; set; } - public virtual int SeriesId { get; set; } - public virtual int EpisodeFileId { get; set; } - public virtual int SeasonNumber { get; set; } - public virtual int EpisodeNumber { get; set; } - public virtual string Title { get; set; } - public virtual DateTime AirDate { get; set; } + public string Overview { get; set; } - public virtual string Overview { get; set; } - - public virtual Boolean Ignored { get; set; } + public Boolean Ignored { get; set; } [Ignore] public Boolean IsDailyEpisode { - get - { - return EpisodeNumber == 0; - } + get { return EpisodeNumber == 0; } } /// @@ -42,7 +37,7 @@ namespace NzbDrone.Core.Repository /// Used to specify when the episode was grapped. /// this filed is used by status as an expirable "Grabbed" status. /// - public virtual DateTime? GrabDate { get; set; } + public DateTime? GrabDate { get; set; } [Ignore] @@ -71,25 +66,21 @@ namespace NzbDrone.Core.Repository [Ignore] - public virtual Series Series { get; set; } + public Series Series { get; set; } [Ignore] - public virtual EpisodeFile EpisodeFile { get; set; } + public EpisodeFile EpisodeFile { get; set; } - [Ignore] - public virtual IList Histories { get; protected set; } - public override string ToString() { - var seriesTitle = Series == null ? "[NULL]" : Series.Title; + string seriesTitle = Series == null ? "[NULL]" : Series.Title; if (IsDailyEpisode) return string.Format("{0} - {1}", seriesTitle, AirDate.Date); return string.Format("{0} - S{1:00}E{2:00}", seriesTitle, SeasonNumber, EpisodeNumber); - } } } \ No newline at end of file diff --git a/NzbDrone.Core/Repository/EpisodeFile.cs b/NzbDrone.Core/Repository/EpisodeFile.cs index 3665a3ca9..0202aba66 100644 --- a/NzbDrone.Core/Repository/EpisodeFile.cs +++ b/NzbDrone.Core/Repository/EpisodeFile.cs @@ -9,10 +9,10 @@ namespace NzbDrone.Core.Repository [PrimaryKey("EpisodeFileId", autoIncrement = true)] public class EpisodeFile { - public virtual int EpisodeFileId { get; set; } + public int EpisodeFileId { get; set; } - public virtual int SeriesId { get; set; } - public virtual int SeasonNumber { get; set; } + public int SeriesId { get; set; } + public int SeasonNumber { get; set; } public string Path { get; set; } public QualityTypes Quality { get; set; } public bool Proper { get; set; } @@ -20,9 +20,9 @@ namespace NzbDrone.Core.Repository public DateTime DateAdded { get; set; } [Ignore] - public virtual IList Episodes { get; set; } + public IList Episodes { get; set; } [Ignore] - public virtual Series Series { get; set; } + public Series Series { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Core/Repository/ExternalNotificationSetting.cs b/NzbDrone.Core/Repository/ExternalNotificationSetting.cs index f4a4686c0..b6d946b69 100644 --- a/NzbDrone.Core/Repository/ExternalNotificationSetting.cs +++ b/NzbDrone.Core/Repository/ExternalNotificationSetting.cs @@ -14,4 +14,4 @@ namespace NzbDrone.Core.Repository public string Name { get; set; } } -} +} \ No newline at end of file diff --git a/NzbDrone.Core/Repository/Quality/QualityProfile.cs b/NzbDrone.Core/Repository/Quality/QualityProfile.cs index 7f1ed347b..fcec6e153 100644 --- a/NzbDrone.Core/Repository/Quality/QualityProfile.cs +++ b/NzbDrone.Core/Repository/Quality/QualityProfile.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; @@ -10,7 +11,6 @@ namespace NzbDrone.Core.Repository.Quality [PrimaryKey("QualityProfileId", autoIncrement = true)] public class QualityProfile { - public virtual int QualityProfileId { get; set; } [Required(ErrorMessage = "A Name is Required")] @@ -49,15 +49,11 @@ namespace NzbDrone.Core.Repository.Quality { var qualities = value.Split('|'); Allowed = new List(qualities.Length); - foreach (var quality in qualities) + foreach (var quality in qualities.Where(q => !String.IsNullOrWhiteSpace(q))) { Allowed.Add((QualityTypes)Convert.ToInt32(quality)); } } } - - [Ignore] - - public virtual List Series { get; private set; } } } \ No newline at end of file diff --git a/NzbDrone.Core/Repository/Quality/QualityTypes.cs b/NzbDrone.Core/Repository/Quality/QualityTypes.cs index 2b7bd1128..c260033a1 100644 --- a/NzbDrone.Core/Repository/Quality/QualityTypes.cs +++ b/NzbDrone.Core/Repository/Quality/QualityTypes.cs @@ -10,32 +10,32 @@ namespace NzbDrone.Core.Repository.Quality /// Quality is unknown /// Unknown = 0, - + /// /// SD File (Source could be HD) /// SDTV = 1, - + /// /// SD File (DVD Source) /// DVD = 2, - + /// /// HD File (HDTV Source) /// HDTV = 4, - + /// /// HD File (Online Source) /// WEBDL = 5, - + /// /// HD File (720p Blu-ray Source) /// Bluray720p = 6, - + /// /// HD File (1080p Blu-ray Source) /// diff --git a/NzbDrone.Core/Repository/SceneMapping.cs b/NzbDrone.Core/Repository/SceneMapping.cs index a5b21a847..5cec317c2 100644 --- a/NzbDrone.Core/Repository/SceneMapping.cs +++ b/NzbDrone.Core/Repository/SceneMapping.cs @@ -6,10 +6,10 @@ namespace NzbDrone.Core.Repository [PrimaryKey("CleanTitle", autoIncrement = false)] public class SceneMapping { - public virtual string CleanTitle { get; set; } + public string CleanTitle { get; set; } - public virtual int SeriesId { get; set; } + public int SeriesId { get; set; } - public virtual string SceneName { get; set; } + public string SceneName { get; set; } } -} +} \ No newline at end of file diff --git a/NzbDrone.Core/Repository/Series.cs b/NzbDrone.Core/Repository/Series.cs index 1f13ba34d..9206026ea 100644 --- a/NzbDrone.Core/Repository/Series.cs +++ b/NzbDrone.Core/Repository/Series.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel; using NzbDrone.Core.Repository.Quality; using PetaPoco; @@ -9,7 +8,6 @@ namespace NzbDrone.Core.Repository [PrimaryKey("SeriesId", autoIncrement = false)] public class Series { - public virtual int SeriesId { get; set; } @@ -38,6 +36,14 @@ namespace NzbDrone.Core.Repository public bool Monitored { get; set; } + public virtual int QualityProfileId { get; set; } + + public bool SeasonFolder { get; set; } + + public DateTime? LastInfoSync { get; set; } + + public DateTime? LastDiskSync { get; set; } + /// /// Gets or sets a value indicating whether this is hidden. /// @@ -47,15 +53,7 @@ namespace NzbDrone.Core.Repository [Ignore] public bool Hidden { get; set; } - public virtual int QualityProfileId { get; set; } - - public bool SeasonFolder { get; set; } - - public DateTime? LastInfoSync { get; set; } - - public DateTime? LastDiskSync { get; set; } - [Ignore] - public virtual QualityProfile QualityProfile { get; set; } + public QualityProfile QualityProfile { get; set; } } } \ No newline at end of file