예제 #1
0
        /// <summary>
        /// Removes a publishing house from the publishing houses list, as well as
        /// from the respective books list.
        /// </summary>
        /// <param name="publishingHouseToRemove">The publishing house to remove</param>
        public void RemovePublishingHouse(PublishingHouse publishingHouseToRemove)
        {
            IUpdateAction removeBooksWithPublishingHouseAction = new DummyAction();

            publishingHouses.Remove(publishingHouseToRemove);

            if (booksWithPublishingHouse.ContainsKey(publishingHouseToRemove) == true)
            {
                removeBooksWithPublishingHouseAction = new DeleteAction(
                    booksWithPublishingHouse[publishingHouseToRemove]);

                foreach (Book currentBook in booksWithPublishingHouse[publishingHouseToRemove])
                {
                    currentBook.PublishingHouse = null;
                }

                booksWithPublishingHouse.Remove(publishingHouseToRemove);
            }

            try
            {
                IUpdateAction removePublishingHouseAction = new DeleteAction(publishingHouseToRemove);
                DatabaseManager.Instance.PerformDataUpdate(removeBooksWithPublishingHouseAction,
                                                           removePublishingHouseAction);
            }

            catch (DatabaseException ex)
            {
                throw new BookEntitiesException(ex.Message, ex);
            }
        }
예제 #2
0
        /// <summary>
        /// Book constructor.
        /// </summary>
        /// <param name="discEntry">The folder and file structure, along with its corresponding
        /// content</param>
        /// <param name="entryPointPath">The path to the file entry point for the book</param>
        /// <param name="isFolderBased">True, if the book is folder based,
        /// false, if the book is file based</param>
        /// <param name="title">The title of the book</param>
        public Book(IDiscEntry discEntry, string entryPointPath, bool isFolderBased, string title)
        {
            this.discEntry      = discEntry;
            this.entryPointPath = entryPointPath;
            this.isFolderBased  = isFolderBased;

            this.title            = title;
            this.authors          = new List <Author>();
            this.tags             = new List <Tag>();
            this.publishingHouse  = null;
            this.yearOfPublishing = null;
        }
예제 #3
0
        public List <Book> GetAllBooksWithPublishingHouse(PublishingHouse aPublishingHouse)
        {
            List <Book> requiredBooks = new List <Book>();

            if (booksWithPublishingHouse.ContainsKey(aPublishingHouse) == true)
            {
                foreach (Book aBook in booksWithPublishingHouse[aPublishingHouse])
                {
                    requiredBooks.Add(aBook);
                }
            }

            return(requiredBooks);
        }
예제 #4
0
        /// <summary>
        /// Renames an existing publishing house.
        /// </summary>
        /// <param name="publishingHouseToRename">The publishing house to be renamed</param>
        /// <param name="newName">The new name for the publishing house</param>
        public void RenamePublishingHouse(PublishingHouse publishingHouseToRename, string newName)
        {
            bool newNameExists = false;

            foreach (PublishingHouse aPublishingHouse in publishingHouses)
            {
                if (aPublishingHouse.Name == newName)
                {
                    newNameExists = true;
                    break;
                }
            }

            if (newNameExists == false)
            {
                publishingHouseToRename.Name = newName;
                publishingHouses.Sort();
            }
        }
예제 #5
0
        public void SetBookPublishingHouse(Book currentBook, PublishingHouse bookPublishingHouse)
        {
            if (currentBook.PublishingHouse != null)
            {
                if (booksWithPublishingHouse.ContainsKey(currentBook.PublishingHouse) == true)
                {
                    booksWithPublishingHouse[currentBook.PublishingHouse].Remove(currentBook);
                }
            }

            currentBook.PublishingHouse = bookPublishingHouse;

            if ((currentBook.PublishingHouse != null) && (bookPublishingHouse != null))
            {
                if (booksWithPublishingHouse.ContainsKey(bookPublishingHouse) == true)
                {
                    booksWithPublishingHouse[bookPublishingHouse].Add(currentBook);
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Adds a new publishing house to the publishing houses list.
        /// </summary>
        /// <param name="newPublishingHouse">The new publishing house</param>
        public void AddPublishingHouse(PublishingHouse newPublishingHouse)
        {
            bool publishingHouseExists = false;

            foreach (PublishingHouse aPublishingHouse in publishingHouses)
            {
                if (aPublishingHouse.Name == newPublishingHouse.Name)
                {
                    publishingHouseExists = true;
                    break;
                }
            }

            if (publishingHouseExists == false)
            {
                publishingHouses.Add(newPublishingHouse);
                publishingHouses.Sort();
                booksWithPublishingHouse[newPublishingHouse] = new List <Book>();
            }
        }