예제 #1
0
        void bAdd_Click(object sender, EventArgs e)
        {
            var book = GetSelectedBook();

            book.Do(b => {
                AllBooks.Remove(b);
                AddRequest(b);
            });
            AllBooks = AllBooks.OrderBy(b => b.Name).ToList();
            gcBooks.Bind(AllBooks);
        }
예제 #2
0
        public void DeleteBook()
        {
            if (MessageBox.Show(String.Format(App.GetString("AreYouSureRemoveBook"), SelectedBook.Title), App.GetString("Removing"),
                                MessageBoxButton.YesNoCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel) != MessageBoxResult.Yes)
            {
                return;
            }

            using (var dbService = _dbServiceManager.GetService())
            {
                dbService.Books.Delete(SelectedBook.Id);
                AllBooks.Remove(SelectedBook);
                Books.Remove(SelectedBook);
            }
        }
예제 #3
0
        public void removeBookIfExists(Book book2)
        {
            if (AllBooks.Count == 0)
            {
                return;
            }
            Book bookToRemove = null;

            foreach (var book in AllBooks)
            {
                if (book.Uniqe_ID.Equals(book2.Uniqe_ID))
                {
                    bookToRemove = book;
                }
            }
            AllBooks.Remove(bookToRemove);
        }
예제 #4
0
 public void DeleteBookMethod()
 {
     if (CheckBook())
     {
         using (Model1 context = new Model1())
         {
             Book OneBook = context.Books.Where(c => c.BookName == BookName)
                            .Include(c => c.Authors).FirstOrDefault();
             context.Books.Remove(OneBook);
             context.SaveChanges();
         }
         AllBooks.Remove(BookName);
     }
     else
     {
         MessageBox.Show("Книга не найдена");
     }
 }
예제 #5
0
 void DeleteBook()
 {
     AllBooks.Remove(SelectedBook);
 }