mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-21 13:37:19 +00:00
Added some extra code around erroneous Qualities in ProfileService
This commit is contained in:
parent
1024555f75
commit
7dcacffec7
2 changed files with 9 additions and 4 deletions
|
@ -6,6 +6,7 @@
|
||||||
using NzbDrone.Core.Parser;
|
using NzbDrone.Core.Parser;
|
||||||
using NzbDrone.Core.Qualities;
|
using NzbDrone.Core.Qualities;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Profiles
|
namespace NzbDrone.Core.Profiles
|
||||||
{
|
{
|
||||||
|
@ -22,13 +23,13 @@ public interface IProfileService
|
||||||
public class ProfileService : IProfileService, IHandle<ApplicationStartedEvent>
|
public class ProfileService : IProfileService, IHandle<ApplicationStartedEvent>
|
||||||
{
|
{
|
||||||
private readonly IProfileRepository _profileRepository;
|
private readonly IProfileRepository _profileRepository;
|
||||||
private readonly ISeriesService _seriesService;
|
private readonly IArtistService _artistService;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public ProfileService(IProfileRepository profileRepository, ISeriesService seriesService, Logger logger)
|
public ProfileService(IProfileRepository profileRepository, IArtistService artistService, Logger logger)
|
||||||
{
|
{
|
||||||
_profileRepository = profileRepository;
|
_profileRepository = profileRepository;
|
||||||
_seriesService = seriesService;
|
_artistService = artistService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ public void Update(Profile profile)
|
||||||
|
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
if (_seriesService.GetAllSeries().Any(c => c.ProfileId == id))
|
if (_artistService.GetAllArtists().Any(c => c.ProfileId == id))
|
||||||
{
|
{
|
||||||
throw new ProfileInUseException(id);
|
throw new ProfileInUseException(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,10 @@ static Quality()
|
||||||
public static Quality FindById(int id)
|
public static Quality FindById(int id)
|
||||||
{
|
{
|
||||||
if (id == 0) return Unknown;
|
if (id == 0) return Unknown;
|
||||||
|
else if (id > AllLookup.Length)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("ID does not match a known quality", nameof(id));
|
||||||
|
}
|
||||||
|
|
||||||
var quality = AllLookup[id];
|
var quality = AllLookup[id];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue