Example #1
0
        /// <summary>
        /// Removes book from database and removes the books authors if no other books are connected to the author.
        /// </summary>
        /// <param name="b">Book to be removed from Database.</param>
        public void Remove(Book b)
        {
            // Searches all authors the book is connected to, to see if they are connected to another book, otherwise, remove the author from DB.
            for (int i = b.Authors.Count() - 1; i >= 0; i--)
            {
                bool keepAuthor = false;
                foreach (Book ab in All()) // Search all books for the specific author.
                {
                    if (ab != b)           // Dont match if the currently searching book is the same as the book about to be removed.
                    {
                        if (ab.Authors.Contains(b.Authors[i]))
                        {
                            keepAuthor = true;
                        }
                    }
                }
                if (keepAuthor == false)
                {
                    authorRepository.Remove(b.Authors[i]);
                }
            }

            bookRepository.Remove(b);
            var e = EventArgs.Empty;

            OnUpdated(e);
        }
Example #2
0
        /// <summary>
        /// Removes the Author from the database and notifies subscribers of the update.
        /// </summary>
        /// <param name="a">Author reference to be removed from the DB</param>
        public void Remove(Author a)
        {
            authorRepository.Remove(a);
            var e = EventArgs.Empty;

            OnUpdated(e);
        }
Example #3
0
 /// <summary>
 /// Removes an author from the repository
 /// </summary>
 /// <param name="author">The author to remove</param>
 public void Remove(Author author)
 {
     authorRepository.Remove(author);
     OnUpdated(this, eventArgs);
 }
Example #4
0
 public void RemoveAuthor(Author author)
 {
     authorRepository.Remove(author);
 }
Example #5
0
 /// <summary>
 /// Removes a specific author from database.
 /// </summary>
 /// <param name="author">Author object to be removed.</param>
 public void Remove(Author author)
 {
     AuthorRepository.Remove(author);
     OnUpdated(author, EventArgs.Empty);
 }