コード例 #1
0
 public void Add(BookType bookType)
 {
     using (LibraryContext libraryContext = new LibraryContext())
     {
         libraryContext.BookType.Add(bookType);
         libraryContext.SaveChanges();
     }
 }
コード例 #2
0
 public void Delete(BookType bookType)
 {
     using (LibraryContext libraryContext = new LibraryContext())
     {
         var entity = libraryContext.Entry(bookType);
         entity.State = EntityState.Deleted;
         libraryContext.SaveChanges();
     }
 }
コード例 #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);
     }
 }