Exemplo n.º 1
0
        private void Edit_Book(DataGrid dataGrid)
        {
            if (dataGrid.SelectedItem is null)
            {
                return;
            }

            BookDto    bookDto        = (BookDto)dataGrid.SelectedItem;
            BookWindow editBookWindow = new BookWindow
            {
                Book          = BookService.FindById(bookDto.Id),
                BookService   = BookService,
                AuthorService = AuthorService,
                BookCounter   = BookCounter,
                BookArranger  = BookArranger
            };


            editBookWindow.ShowDialog();
            dataGrid.Items.Refresh();
        }
Exemplo n.º 2
0
        private void New_Book_Button_Click(object sender, RoutedEventArgs args)
        {
            BookWindow bookWindow = new BookWindow
            {
                Book          = new Book(),
                BookService   = BookService,
                AuthorService = AuthorService,
                BookCounter   = BookCounter,
                BookArranger  = BookArranger
            };

            BookDtoConverter dtoConverter = new BookDtoConverter {
                BookCounter  = BookCounter,
                BookArranger = BookArranger
            };

            bookWindow.ShowDialog();
            if (bookWindow.BookIsSaved)
            {
                ((IList <BookDto>)allBooksDataGrid.ItemsSource).Add(dtoConverter.ConvertBook(bookWindow.Book));
                allBooksDataGrid.Items.Refresh();
            }
        }