Fixed Series.QualityProfile relationship

more subsonic cleanup
pull/4/head
kay.one 14 years ago
parent 17d084cdf3
commit 520e9c9d14

@ -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<QualityProfile>(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()
{

@ -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<QualityProfile>(profileId);
return _database.Single<QualityProfile>(profileId);
}
public virtual void SetupDefaultProfiles()

@ -38,13 +38,18 @@ namespace NzbDrone.Core.Providers
public virtual IList<Series> GetAllSeries()
{
var series = _database.Fetch<Series>();
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<Series>("WHERE seriesId= @0", seriesId);
var series = _database.SingleOrDefault<Series>("WHERE seriesId= @0", seriesId);
if (series != null)
{
series.QualityProfile = _qualityProvider.Get(series.QualityProfileId);
}
return series;
}
/// <summary>

@ -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; }
}
/// <summary>
@ -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.
/// </remarks>
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<History> 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);
}
}
}

@ -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<Episode> Episodes { get; set; }
public IList<Episode> Episodes { get; set; }
[Ignore]
public virtual Series Series { get; set; }
public Series Series { get; set; }
}
}

@ -14,4 +14,4 @@ namespace NzbDrone.Core.Repository
public string Name { get; set; }
}
}
}

@ -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<QualityTypes>(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> Series { get; private set; }
}
}

@ -10,32 +10,32 @@ namespace NzbDrone.Core.Repository.Quality
/// Quality is unknown
/// </summary>
Unknown = 0,
/// <summary>
/// SD File (Source could be HD)
/// </summary>
SDTV = 1,
/// <summary>
/// SD File (DVD Source)
/// </summary>
DVD = 2,
/// <summary>
/// HD File (HDTV Source)
/// </summary>
HDTV = 4,
/// <summary>
/// HD File (Online Source)
/// </summary>
WEBDL = 5,
/// <summary>
/// HD File (720p Blu-ray Source)
/// </summary>
Bluray720p = 6,
/// <summary>
/// HD File (1080p Blu-ray Source)
/// </summary>

@ -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; }
}
}
}

@ -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; }
/// <summary>
/// Gets or sets a value indicating whether this <see cref="Series"/> is hidden.
/// </summary>
@ -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; }
}
}
Loading…
Cancel
Save