2017-03-04 02:32:52 +00:00
|
|
|
|
using FluentValidation;
|
|
|
|
|
using NzbDrone.Api.ClientSchema;
|
2017-01-21 21:13:55 +00:00
|
|
|
|
using NzbDrone.Core.NetImport;
|
2017-03-04 02:32:52 +00:00
|
|
|
|
using NzbDrone.Core.Validation.Paths;
|
2017-01-21 20:09:02 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.NetImport
|
|
|
|
|
{
|
|
|
|
|
public class NetImportModule : ProviderModuleBase<NetImportResource, INetImport, NetImportDefinition>
|
|
|
|
|
{
|
2017-03-04 02:32:52 +00:00
|
|
|
|
public NetImportModule(NetImportFactory netImportFactory) : base(netImportFactory, "netimport")
|
2017-01-21 20:09:02 +00:00
|
|
|
|
{
|
2017-07-08 14:13:28 +00:00
|
|
|
|
PostValidator.RuleFor(c => c.RootFolderPath).IsValidPath();
|
2017-03-04 02:32:52 +00:00
|
|
|
|
PostValidator.RuleFor(c => c.MinimumAvailability).NotNull();
|
|
|
|
|
PostValidator.RuleFor(c => c.ProfileId).NotNull();
|
2017-01-21 20:09:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void MapToResource(NetImportResource resource, NetImportDefinition definition)
|
|
|
|
|
{
|
|
|
|
|
base.MapToResource(resource, definition);
|
|
|
|
|
|
|
|
|
|
resource.Enabled = definition.Enabled;
|
2017-01-22 16:02:20 +00:00
|
|
|
|
resource.EnableAuto = definition.EnableAuto;
|
|
|
|
|
resource.ProfileId = definition.ProfileId;
|
2017-01-23 14:21:49 +00:00
|
|
|
|
resource.RootFolderPath = definition.RootFolderPath;
|
2017-01-23 14:31:09 +00:00
|
|
|
|
resource.ShouldMonitor = definition.ShouldMonitor;
|
2017-02-23 05:03:48 +00:00
|
|
|
|
resource.MinimumAvailability = definition.MinimumAvailability;
|
2019-05-02 10:57:40 +00:00
|
|
|
|
resource.Tags = definition.Tags;
|
2017-01-21 20:09:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void MapToModel(NetImportDefinition definition, NetImportResource resource)
|
|
|
|
|
{
|
|
|
|
|
base.MapToModel(definition, resource);
|
|
|
|
|
|
2017-01-22 16:02:20 +00:00
|
|
|
|
definition.Enabled = resource.Enabled;
|
|
|
|
|
definition.EnableAuto = resource.EnableAuto;
|
|
|
|
|
definition.ProfileId = resource.ProfileId;
|
2017-01-23 14:21:49 +00:00
|
|
|
|
definition.RootFolderPath = resource.RootFolderPath;
|
2017-01-23 14:31:09 +00:00
|
|
|
|
definition.ShouldMonitor = resource.ShouldMonitor;
|
2017-02-23 05:03:48 +00:00
|
|
|
|
definition.MinimumAvailability = resource.MinimumAvailability;
|
2019-05-02 10:57:40 +00:00
|
|
|
|
definition.Tags = resource.Tags;
|
2017-01-21 20:09:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Validate(NetImportDefinition definition, bool includeWarnings)
|
|
|
|
|
{
|
|
|
|
|
if (!definition.Enable) return;
|
|
|
|
|
base.Validate(definition, includeWarnings);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-23 05:03:48 +00:00
|
|
|
|
}
|