コード例 #1
0
        private void EditBook()
        {
            var item = BookDataGrid.SelectedItem as BookDataGridItem;

            if (item == null)
            {
                MessageBox.Show("Select a book for editation.", "Book Manager - Notice", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                return;
            }

            // We Reload here to make sure, that we get, what is  in the DB.
            var entity = Registry.Get <BookDataLayer>().Reload(item.Id);

            if (entity == null)
            {
                MessageBox.Show("The selected book can not be read for editation.", "Book Manager - Error", MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            if (BookEditorWindow.Open(Gdo, entity))
            {
                Registry.Get <BookDataLayer>().Save(entity);

                Update();
            }
        }
コード例 #2
0
        private void AddBook()
        {
            var obj = new Book();

            if (BookEditorWindow.Open(Gdo, obj))
            {
                Registry.Get <BookDataLayer>().Save(obj);

                Update();
            }
        }