mirror of
https://github.com/ckaczor/FeedCenter.git
synced 2026-01-13 17:22:48 -05:00
- Modernize old async code - Update to .NET 10 - Adjust namespace - Bypass update check when debugging
53 lines
1.2 KiB
C#
53 lines
1.2 KiB
C#
using ChrisKaczor.Wpf.Validation;
|
|
using System.Windows;
|
|
using FeedCenter.Feeds;
|
|
|
|
namespace FeedCenter.Options;
|
|
|
|
public partial class CategoryWindow
|
|
{
|
|
private readonly FeedCenterEntities _entities;
|
|
|
|
public CategoryWindow(FeedCenterEntities entities)
|
|
{
|
|
_entities = entities;
|
|
|
|
InitializeComponent();
|
|
}
|
|
|
|
public bool? Display(Category category, Window owner)
|
|
{
|
|
// Set the data context
|
|
DataContext = category;
|
|
|
|
// Set the title based on the state of the category
|
|
Title = string.IsNullOrWhiteSpace(category.Name)
|
|
? Properties.Resources.CategoryWindowAdd
|
|
: Properties.Resources.CategoryWindowEdit;
|
|
|
|
// Set the window owner
|
|
Owner = owner;
|
|
|
|
// Show the dialog and result the result
|
|
return ShowDialog();
|
|
}
|
|
|
|
private void HandleOkayButtonClick(object sender, RoutedEventArgs e)
|
|
{
|
|
var transaction = _entities.BeginTransaction();
|
|
|
|
if (!this.IsValid())
|
|
{
|
|
transaction.Rollback();
|
|
return;
|
|
}
|
|
|
|
transaction.Commit();
|
|
|
|
// Dialog is good
|
|
DialogResult = true;
|
|
|
|
// Close the dialog
|
|
Close();
|
|
}
|
|
} |