예제 #1
0
        public static BookCategory EditBookCategory(Window owner, GlobalDataObject gdo, object source, bool isNew = false, bool updateColection = true)
        {
            var entity = GetEntityForEditation <BookCategory>(owner, source, gdo.GetBookCategory, isNew);

            if (entity == null)
            {
                return(null);
            }

            if (BookCategoryEditorWindow.Open(entity))
            {
                gdo.SaveBookCategory(entity);

                if (updateColection)
                {
                    UpdateBookCategoryCollection(owner, gdo);
                }
            }

            return(entity);
        }
        public static bool Open(BookCategory dataObject)
        {
            if (dataObject == null)
            {
                throw new ArgumentNullException("dataObject");
            }

            var dialog = new BookCategoryEditorWindow()
            {
                DataContext           = dataObject,
                Owner                 = Registry.Get <MainWindow>(),
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                Title                 = (dataObject.Id <= 0)
                    ? "Book Manager - New Book Category"
                    : String.Format("Book Manager - Book Category Edit {0}", dataObject.Id)
            };

            dialog.ShowDialog();

            return(dialog.DialogResult.GetValueOrDefault());
        }