public BookModule(IAuthorService authorService, IBookService bookService, IAddBookService addBookService, IEditionService editionService, ISeriesBookLinkService seriesBookLinkService, IAuthorStatisticsService authorStatisticsService, IMapCoversToLocal coverMapper, IUpgradableSpecification upgradableSpecification, IBroadcastSignalRMessage signalRBroadcaster, QualityProfileExistsValidator qualityProfileExistsValidator, MetadataProfileExistsValidator metadataProfileExistsValidator) : base(bookService, seriesBookLinkService, authorStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster) { _authorService = authorService; _editionService = editionService; _addBookService = addBookService; GetResourceAll = GetBooks; CreateResource = AddBook; UpdateResource = UpdateBook; DeleteResource = DeleteBook; Put("/monitor", x => SetBooksMonitored()); PostValidator.RuleFor(s => s.ForeignBookId).NotEmpty(); PostValidator.RuleFor(s => s.Author.QualityProfileId).SetValidator(qualityProfileExistsValidator); PostValidator.RuleFor(s => s.Author.MetadataProfileId).SetValidator(metadataProfileExistsValidator); PostValidator.RuleFor(s => s.Author.RootFolderPath).IsValidPath().When(s => s.Author.Path.IsNullOrWhiteSpace()); PostValidator.RuleFor(s => s.Author.ForeignAuthorId).NotEmpty(); }
public AlbumModule(IArtistService artistService, IAlbumService albumService, IAddAlbumService addAlbumService, IReleaseService releaseService, IArtistStatisticsService artistStatisticsService, IMapCoversToLocal coverMapper, IUpgradableSpecification upgradableSpecification, IBroadcastSignalRMessage signalRBroadcaster, QualityProfileExistsValidator qualityProfileExistsValidator, MetadataProfileExistsValidator metadataProfileExistsValidator) : base(albumService, artistStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster) { _artistService = artistService; _releaseService = releaseService; _addAlbumService = addAlbumService; GetResourceAll = GetAlbums; CreateResource = AddAlbum; UpdateResource = UpdateAlbum; DeleteResource = DeleteAlbum; Put("/monitor", x => SetAlbumsMonitored()); PostValidator.RuleFor(s => s.ForeignAlbumId).NotEmpty(); PostValidator.RuleFor(s => s.Artist.QualityProfileId).SetValidator(qualityProfileExistsValidator); PostValidator.RuleFor(s => s.Artist.MetadataProfileId).SetValidator(metadataProfileExistsValidator); PostValidator.RuleFor(s => s.Artist.RootFolderPath).IsValidPath().When(s => s.Artist.Path.IsNullOrWhiteSpace()); PostValidator.RuleFor(s => s.Artist.ForeignArtistId).NotEmpty(); }
public RootFolderModule(IRootFolderService rootFolderService, ICalibreProxy calibreProxy, IBroadcastSignalRMessage signalRBroadcaster, RootFolderValidator rootFolderValidator, PathExistsValidator pathExistsValidator, MappedNetworkDriveValidator mappedNetworkDriveValidator, StartupFolderValidator startupFolderValidator, SystemFolderValidator systemFolderValidator, FolderWritableValidator folderWritableValidator, QualityProfileExistsValidator qualityProfileExistsValidator, MetadataProfileExistsValidator metadataProfileExistsValidator) : base(signalRBroadcaster) { _rootFolderService = rootFolderService; _calibreProxy = calibreProxy; GetResourceAll = GetRootFolders; GetResourceById = GetRootFolder; CreateResource = CreateRootFolder; UpdateResource = UpdateRootFolder; DeleteResource = DeleteFolder; SharedValidator.RuleFor(c => c.Path) .Cascade(CascadeMode.StopOnFirstFailure) .IsValidPath() .SetValidator(mappedNetworkDriveValidator) .SetValidator(startupFolderValidator) .SetValidator(pathExistsValidator) .SetValidator(systemFolderValidator) .SetValidator(folderWritableValidator); PostValidator.RuleFor(c => c.Path) .SetValidator(rootFolderValidator); SharedValidator.RuleFor(c => c) .Must(x => CalibreLibraryOnlyUsedOnce(x)) .When(x => x.IsCalibreLibrary) .WithMessage("Calibre library is already configured as a root folder"); SharedValidator.RuleFor(c => c.Name) .NotEmpty(); SharedValidator.RuleFor(c => c.DefaultMetadataProfileId) .SetValidator(metadataProfileExistsValidator); SharedValidator.RuleFor(c => c.DefaultQualityProfileId) .SetValidator(qualityProfileExistsValidator); SharedValidator.RuleFor(c => c.Host).ValidHost().When(x => x.IsCalibreLibrary); SharedValidator.RuleFor(c => c.Port).InclusiveBetween(1, 65535).When(x => x.IsCalibreLibrary); SharedValidator.RuleFor(c => c.UrlBase).ValidUrlBase().When(c => c.UrlBase.IsNotNullOrWhiteSpace()); SharedValidator.RuleFor(c => c.Username).NotEmpty().When(c => !string.IsNullOrWhiteSpace(c.Password)); SharedValidator.RuleFor(c => c.Password).NotEmpty().When(c => !string.IsNullOrWhiteSpace(c.Username)); SharedValidator.RuleFor(c => c.OutputFormat).Must(x => x.Split(',').All(y => Enum.TryParse <CalibreFormat>(y, true, out _))).When(x => x.OutputFormat.IsNotNullOrWhiteSpace()).WithMessage("Invalid output formats"); SharedValidator.RuleFor(c => c.OutputProfile).IsEnumName(typeof(CalibreProfile)); }
public ArtistModule(IBroadcastSignalRMessage signalRBroadcaster, IArtistService artistService, IAlbumService albumService, IAddArtistService addArtistService, IArtistStatisticsService artistStatisticsService, IMapCoversToLocal coverMapper, IManageCommandQueue commandQueueManager, IRootFolderService rootFolderService, RootFolderValidator rootFolderValidator, MappedNetworkDriveValidator mappedNetworkDriveValidator, ArtistPathValidator artistPathValidator, ArtistExistsValidator artistExistsValidator, ArtistAncestorValidator artistAncestorValidator, SystemFolderValidator systemFolderValidator, QualityProfileExistsValidator qualityProfileExistsValidator, MetadataProfileExistsValidator metadataProfileExistsValidator) : base(signalRBroadcaster) { _artistService = artistService; _albumService = albumService; _addArtistService = addArtistService; _artistStatisticsService = artistStatisticsService; _coverMapper = coverMapper; _commandQueueManager = commandQueueManager; _rootFolderService = rootFolderService; GetResourceAll = AllArtists; GetResourceById = GetArtist; CreateResource = AddArtist; UpdateResource = UpdateArtist; DeleteResource = DeleteArtist; Http.Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.QualityProfileId)); Http.Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.MetadataProfileId)); SharedValidator.RuleFor(s => s.Path) .Cascade(CascadeMode.StopOnFirstFailure) .IsValidPath() .SetValidator(rootFolderValidator) .SetValidator(mappedNetworkDriveValidator) .SetValidator(artistPathValidator) .SetValidator(artistAncestorValidator) .SetValidator(systemFolderValidator) .When(s => !s.Path.IsNullOrWhiteSpace()); SharedValidator.RuleFor(s => s.QualityProfileId).SetValidator(qualityProfileExistsValidator); SharedValidator.RuleFor(s => s.MetadataProfileId).SetValidator(metadataProfileExistsValidator); PostValidator.RuleFor(s => s.Path).IsValidPath().When(s => s.RootFolderPath.IsNullOrWhiteSpace()); PostValidator.RuleFor(s => s.RootFolderPath).IsValidPath().When(s => s.Path.IsNullOrWhiteSpace()); PostValidator.RuleFor(s => s.ArtistName).NotEmpty(); PostValidator.RuleFor(s => s.ForeignArtistId).NotEmpty().SetValidator(artistExistsValidator); PutValidator.RuleFor(s => s.Path).IsValidPath(); }
public ImportListController(IImportListFactory importListFactory, QualityProfileExistsValidator qualityProfileExistsValidator, MetadataProfileExistsValidator metadataProfileExistsValidator) : base(importListFactory, "importlist", ResourceMapper) { Http.Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.QualityProfileId)); Http.Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.MetadataProfileId)); SharedValidator.RuleFor(c => c.RootFolderPath).IsValidPath(); SharedValidator.RuleFor(c => c.QualityProfileId).SetValidator(qualityProfileExistsValidator); SharedValidator.RuleFor(c => c.MetadataProfileId).SetValidator(metadataProfileExistsValidator); }
public AuthorController(IBroadcastSignalRMessage signalRBroadcaster, IAuthorService authorService, IBookService bookService, IAddAuthorService addAuthorService, IAuthorStatisticsService authorStatisticsService, IMapCoversToLocal coverMapper, IManageCommandQueue commandQueueManager, IRootFolderService rootFolderService, RecycleBinValidator recycleBinValidator, RootFolderValidator rootFolderValidator, MappedNetworkDriveValidator mappedNetworkDriveValidator, AuthorPathValidator authorPathValidator, AuthorExistsValidator authorExistsValidator, AuthorAncestorValidator authorAncestorValidator, SystemFolderValidator systemFolderValidator, QualityProfileExistsValidator qualityProfileExistsValidator, MetadataProfileExistsValidator metadataProfileExistsValidator) : base(signalRBroadcaster) { _authorService = authorService; _bookService = bookService; _addAuthorService = addAuthorService; _authorStatisticsService = authorStatisticsService; _coverMapper = coverMapper; _commandQueueManager = commandQueueManager; _rootFolderService = rootFolderService; Http.Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.QualityProfileId)); Http.Validation.RuleBuilderExtensions.ValidId(SharedValidator.RuleFor(s => s.MetadataProfileId)); SharedValidator.RuleFor(s => s.Path) .Cascade(CascadeMode.StopOnFirstFailure) .IsValidPath() .SetValidator(rootFolderValidator) .SetValidator(mappedNetworkDriveValidator) .SetValidator(authorPathValidator) .SetValidator(authorAncestorValidator) .SetValidator(recycleBinValidator) .SetValidator(systemFolderValidator) .When(s => !s.Path.IsNullOrWhiteSpace()); SharedValidator.RuleFor(s => s.QualityProfileId).SetValidator(qualityProfileExistsValidator); SharedValidator.RuleFor(s => s.MetadataProfileId).SetValidator(metadataProfileExistsValidator); PostValidator.RuleFor(s => s.Path).IsValidPath().When(s => s.RootFolderPath.IsNullOrWhiteSpace()); PostValidator.RuleFor(s => s.RootFolderPath).IsValidPath().When(s => s.Path.IsNullOrWhiteSpace()); PostValidator.RuleFor(s => s.AuthorName).NotEmpty(); PostValidator.RuleFor(s => s.ForeignAuthorId).NotEmpty().SetValidator(authorExistsValidator); PutValidator.RuleFor(s => s.Path).IsValidPath(); }
public AddArtistValidator(RootFolderValidator rootFolderValidator, ArtistPathValidator artistPathValidator, ArtistAncestorValidator artistAncestorValidator, QualityProfileExistsValidator qualityProfileExistsValidator, MetadataProfileExistsValidator metadataProfileExistsValidator) { RuleFor(c => c.Path).Cascade(CascadeMode.StopOnFirstFailure) .IsValidPath() .SetValidator(rootFolderValidator) .SetValidator(artistPathValidator) .SetValidator(artistAncestorValidator); RuleFor(c => c.QualityProfileId).SetValidator(qualityProfileExistsValidator); RuleFor(c => c.MetadataProfileId).SetValidator(metadataProfileExistsValidator); }
public RootFolderModule(IRootFolderService rootFolderService, IBroadcastSignalRMessage signalRBroadcaster, RootFolderValidator rootFolderValidator, PathExistsValidator pathExistsValidator, MappedNetworkDriveValidator mappedNetworkDriveValidator, StartupFolderValidator startupFolderValidator, SystemFolderValidator systemFolderValidator, FolderWritableValidator folderWritableValidator, QualityProfileExistsValidator qualityProfileExistsValidator, MetadataProfileExistsValidator metadataProfileExistsValidator) : base(signalRBroadcaster) { _rootFolderService = rootFolderService; GetResourceAll = GetRootFolders; GetResourceById = GetRootFolder; CreateResource = CreateRootFolder; UpdateResource = UpdateRootFolder; DeleteResource = DeleteFolder; SharedValidator.RuleFor(c => c.Path) .Cascade(CascadeMode.StopOnFirstFailure) .IsValidPath() .SetValidator(mappedNetworkDriveValidator) .SetValidator(startupFolderValidator) .SetValidator(pathExistsValidator) .SetValidator(systemFolderValidator) .SetValidator(folderWritableValidator); PostValidator.RuleFor(c => c.Path) .SetValidator(rootFolderValidator); SharedValidator.RuleFor(c => c.Name) .NotEmpty(); SharedValidator.RuleFor(c => c.DefaultMetadataProfileId) .SetValidator(metadataProfileExistsValidator); SharedValidator.RuleFor(c => c.DefaultQualityProfileId) .SetValidator(qualityProfileExistsValidator); }
public BookController(IAuthorService authorService, IBookService bookService, IAddBookService addBookService, IEditionService editionService, ISeriesBookLinkService seriesBookLinkService, IAuthorStatisticsService authorStatisticsService, IMapCoversToLocal coverMapper, IUpgradableSpecification upgradableSpecification, IBroadcastSignalRMessage signalRBroadcaster, QualityProfileExistsValidator qualityProfileExistsValidator, MetadataProfileExistsValidator metadataProfileExistsValidator) : base(bookService, seriesBookLinkService, authorStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster) { _authorService = authorService; _editionService = editionService; _addBookService = addBookService; PostValidator.RuleFor(s => s.ForeignBookId).NotEmpty(); PostValidator.RuleFor(s => s.Author.QualityProfileId).SetValidator(qualityProfileExistsValidator); PostValidator.RuleFor(s => s.Author.MetadataProfileId).SetValidator(metadataProfileExistsValidator); PostValidator.RuleFor(s => s.Author.RootFolderPath).IsValidPath().When(s => s.Author.Path.IsNullOrWhiteSpace()); PostValidator.RuleFor(s => s.Author.ForeignAuthorId).NotEmpty(); }