mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-20 21:55:03 -04:00
aab425ee5b
* few small things * update var names * Validate Root Folder, Minimum Avability and ProfileId on List import.
48 lines
1.9 KiB
C#
48 lines
1.9 KiB
C#
using FluentValidation;
|
|
using NzbDrone.Api.ClientSchema;
|
|
using NzbDrone.Core.NetImport;
|
|
using NzbDrone.Core.Validation.Paths;
|
|
|
|
namespace NzbDrone.Api.NetImport
|
|
{
|
|
public class NetImportModule : ProviderModuleBase<NetImportResource, INetImport, NetImportDefinition>
|
|
{
|
|
public NetImportModule(NetImportFactory netImportFactory) : base(netImportFactory, "netimport")
|
|
{
|
|
PostValidator.RuleFor(c => c.RootFolderPath).NotNull();
|
|
PostValidator.RuleFor(c => c.MinimumAvailability).NotNull();
|
|
PostValidator.RuleFor(c => c.ProfileId).NotNull();
|
|
}
|
|
|
|
protected override void MapToResource(NetImportResource resource, NetImportDefinition definition)
|
|
{
|
|
base.MapToResource(resource, definition);
|
|
|
|
resource.Enabled = definition.Enabled;
|
|
resource.EnableAuto = definition.EnableAuto;
|
|
resource.ProfileId = definition.ProfileId;
|
|
resource.RootFolderPath = definition.RootFolderPath;
|
|
resource.ShouldMonitor = definition.ShouldMonitor;
|
|
resource.MinimumAvailability = definition.MinimumAvailability;
|
|
}
|
|
|
|
protected override void MapToModel(NetImportDefinition definition, NetImportResource resource)
|
|
{
|
|
base.MapToModel(definition, resource);
|
|
|
|
definition.Enabled = resource.Enabled;
|
|
definition.EnableAuto = resource.EnableAuto;
|
|
definition.ProfileId = resource.ProfileId;
|
|
definition.RootFolderPath = resource.RootFolderPath;
|
|
definition.ShouldMonitor = resource.ShouldMonitor;
|
|
definition.MinimumAvailability = resource.MinimumAvailability;
|
|
}
|
|
|
|
protected override void Validate(NetImportDefinition definition, bool includeWarnings)
|
|
{
|
|
if (!definition.Enable) return;
|
|
base.Validate(definition, includeWarnings);
|
|
}
|
|
}
|
|
}
|