Ejemplo n.º 1
0
        public Book AddBook(Book book, bool doRefresh = true)
        {
            _logger.Debug($"Adding book {book}");

            // we allow adding extra editions, so check if the book already exists
            var dbBook = _bookService.FindById(book.ForeignBookId);

            if (dbBook != null)
            {
                dbBook.Editions = book.Editions;
                book            = dbBook;
            }
            else
            {
                book = AddSkyhookData(book);
            }

            // Remove any import list exclusions preventing addition
            _importListExclusionService.Delete(book.ForeignBookId);
            _importListExclusionService.Delete(book.AuthorMetadata.Value.ForeignAuthorId);

            // Note it's a manual addition so it's not deleted on next refresh
            book.AddOptions.AddType = BookAddType.Manual;
            book.Editions.Value.Single(x => x.Monitored).ManualAdd = true;

            // Add the author if necessary
            var dbAuthor = _authorService.FindById(book.AuthorMetadata.Value.ForeignAuthorId);

            if (dbAuthor == null)
            {
                var author = book.Author.Value;

                author.Metadata.Value.ForeignAuthorId = book.AuthorMetadata.Value.ForeignAuthorId;

                dbAuthor = _addAuthorService.AddAuthor(author, false);
            }

            book.Author           = dbAuthor;
            book.AuthorMetadataId = dbAuthor.AuthorMetadataId;
            _bookService.AddBook(book, doRefresh);

            return(book);
        }
Ejemplo n.º 2
0
        public Album AddAlbum(Album album, bool doRefresh = true)
        {
            _logger.Debug($"Adding album {album}");

            album = AddSkyhookData(album);

            // Remove any import list exclusions preventing addition
            _importListExclusionService.Delete(album.ForeignAlbumId);
            _importListExclusionService.Delete(album.ArtistMetadata.Value.ForeignArtistId);

            // Note it's a manual addition so it's not deleted on next refresh
            album.AddOptions.AddType = AlbumAddType.Manual;

            // Add the artist if necessary
            var dbArtist = _artistService.FindById(album.ArtistMetadata.Value.ForeignArtistId);

            if (dbArtist == null)
            {
                var artist = album.Artist.Value;

                artist.Metadata.Value.ForeignArtistId = album.ArtistMetadata.Value.ForeignArtistId;

                // if adding and searching for artist, don't trigger album specific search
                if (artist.AddOptions?.SearchForMissingAlbums ?? false)
                {
                    album.AddOptions.SearchForNewAlbum = false;
                }

                dbArtist = _addArtistService.AddArtist(artist, false);
            }

            album.ArtistMetadataId = dbArtist.ArtistMetadataId;
            album.Artist           = dbArtist;
            _albumService.AddAlbum(album, doRefresh);

            return(album);
        }
Ejemplo n.º 3
0
 private void DeleteImportListExclusionResource(int id)
 {
     _importListExclusionService.Delete(id);
 }