示例#1
0
 /// <summary>
 /// Usuwa istniejącego w bazie autora.
 /// </summary>
 /// <param name="authorToRemove">Autor, który ma zostać usunięty z bazy</param>
 public void RemoveAuthor(Author authorToRemove)
 {
     using (BookshelfContext context = new BookshelfContext())
     {
         context.Remove(authorToRemove);
         context.SaveChanges();
     }
 }
示例#2
0
 /// <summary>
 /// Usuwa istniejącą w bazie półkę.
 /// </summary>
 /// <param name="shelfToRemove">Półka, która ma zostać usunięta z bazy</param>
 public void RemoveShelf(Shelf shelfToRemove)
 {
     using (BookshelfContext context = new BookshelfContext())
     {
         context.Remove(shelfToRemove);
         context.SaveChanges();
     }
 }
示例#3
0
 /// <summary>
 /// Usuwa istniejący w bazie gatunek.
 /// </summary>
 /// <param name="genereToRemove">Gatunek, który ma zostać usunięty z bazy</param>
 public void RemoveGenere(Genere genereToRemove)
 {
     using (BookshelfContext context = new BookshelfContext())
     {
         context.Remove(genereToRemove);
         context.SaveChanges();
     }
 }
示例#4
0
        /// <summary>
        /// Usuwa autora z danej książki.
        /// </summary>
        /// <param name="book">Książka, z której ma zostać usunięty dany autor</param>
        /// <param name="author">Autor, który ma zostać usunięty z danej książki</param>
        public void RemoveAuthorFromBook(Book book, Author author)
        {
            if (book == null || author == null)
            {
                throw new ArgumentNullException();
            }

            using (BookshelfContext context = new BookshelfContext())
            {
                context.Remove(new BookAuthor()
                {
                    BookId   = book.BookId,
                    AuthorId = author.AuthorId
                });
                context.SaveChanges();
            }
        }
示例#5
0
        /// <summary>
        /// Usuwa istniejącą w bazie książkę.
        /// </summary>
        /// <param name="bookToRemove">Książka, która ma zostać usunieta</param>
        public void RemoveBook(Book bookToRemove)
        {
            if (bookToRemove == null)
            {
                throw new ArgumentNullException();
            }

            foreach (Author bookAuthor in GetBookAuthors(bookToRemove))
            {
                RemoveAuthorFromBook(bookToRemove, bookAuthor);
            }

            using (BookshelfContext context = new BookshelfContext())
            {
                context.Remove(bookToRemove);
                context.SaveChanges();
            }
        }