public void Add(BookType bookType)
 {
     using (LibraryContext libraryContext = new LibraryContext())
     {
         libraryContext.BookType.Add(bookType);
         libraryContext.SaveChanges();
     }
 }
 public void Delete(BookType bookType)
 {
     using (LibraryContext libraryContext = new LibraryContext())
     {
         var entity = libraryContext.Entry(bookType);
         entity.State = EntityState.Deleted;
         libraryContext.SaveChanges();
     }
 }
Exemple #3
0
 public bool UpdateBookBookType(Book book, BookType bookType, out string message)
 {
     try
     {
         using (LiteDatabase db = new LiteDatabase(@"library.db"))
         {
             var books = db.GetCollection <Book>("Books");
             book.BookType = bookType;
             books.Update(book);
         }
         message = string.Format("Жанр книги {0} изменен на {1}", book.Id, bookType);
         return(true);
     }
     catch (Exception ex)
     {
         message = ex.Message;
         return(false);
     }
 }