diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml.cs index 6bcccf7..e94c515 100644 --- a/WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml.cs +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml.cs @@ -1,4 +1,5 @@ using System.Windows; +using WD7UVN_SzTGUI_2023242.Client.WPF.Windows; namespace WD7UVN_SzTGUI_2023242.Client.WPF { @@ -20,17 +21,20 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF private void ExpandAllCustomers(object sender, RoutedEventArgs e) { - + Window window = new GetAllCustomers(); + window.Show(); } private void ExpandAllEmployees(object sender, RoutedEventArgs e) { - + Window window = new GetAllEmployees(); + window.Show(); } private void ExpandAllMaintainerTeams(object sender, RoutedEventArgs e) { - + Window window = new GetAllMaintainerTeams(); + window.Show(); } } } diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllCustomersViewModel.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllCustomersViewModel.cs new file mode 100644 index 0000000..b3f6872 --- /dev/null +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllCustomersViewModel.cs @@ -0,0 +1,50 @@ +using WD7UVN_HFT_2023241.Models; +using System.ComponentModel; +using System.Windows; +using CommunityToolkit.Mvvm.ComponentModel; +using System.Windows.Input; +using CommunityToolkit.Mvvm.Input; + +namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels +{ + public class GetAllCustomersViewModel : ObservableRecipient + { + public RestCollection Customers { get; set; } + + private Customer selectedCustomer; + + public Customer SelectedCustomer + { + get { return selectedCustomer; } + set { SetProperty(ref selectedCustomer, value); (UpdateCustomerCommand as RelayCommand).NotifyCanExecuteChanged(); } + } + + public ICommand UpdateCustomerCommand { get; set; } + + public static bool IsInDesignMode + { + get + { + var prop = DesignerProperties.IsInDesignModeProperty; + return (bool)DependencyPropertyDescriptor.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue; + } + } + + public GetAllCustomersViewModel() + { + if (!IsInDesignMode) + { + Customers = new RestCollection("http://localhost:5000/", "api/Customer", "hub"); + + UpdateCustomerCommand = new RelayCommand(() => + { + Customers.Update(SelectedCustomer); + }, + () => + { + return SelectedCustomer != null; + }); + } + } + } +} diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllEmployeesViewModel.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllEmployeesViewModel.cs new file mode 100644 index 0000000..8361f9c --- /dev/null +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllEmployeesViewModel.cs @@ -0,0 +1,50 @@ +using WD7UVN_HFT_2023241.Models; +using System.ComponentModel; +using System.Windows; +using CommunityToolkit.Mvvm.ComponentModel; +using System.Windows.Input; +using CommunityToolkit.Mvvm.Input; + +namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels +{ + public class GetAllEmployeesViewModel : ObservableRecipient + { + public RestCollection Employees { get; set; } + + private Employee selectedEmployee; + + public Employee SelectedEmployee + { + get { return selectedEmployee; } + set { SetProperty(ref selectedEmployee, value); (UpdateEmployeeCommand as RelayCommand).NotifyCanExecuteChanged(); } + } + + public ICommand UpdateEmployeeCommand { get; set; } + + public static bool IsInDesignMode + { + get + { + var prop = DesignerProperties.IsInDesignModeProperty; + return (bool)DependencyPropertyDescriptor.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue; + } + } + + public GetAllEmployeesViewModel() + { + if (!IsInDesignMode) + { + Employees = new RestCollection("http://localhost:5000/", "api/Employee", "hub"); + + UpdateEmployeeCommand = new RelayCommand(() => + { + Employees.Update(SelectedEmployee); + }, + () => + { + return SelectedEmployee != null; + }); + } + } + } +} diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllMaintainerTeamsViewModel.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllMaintainerTeamsViewModel.cs new file mode 100644 index 0000000..f0fd541 --- /dev/null +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllMaintainerTeamsViewModel.cs @@ -0,0 +1,50 @@ +using WD7UVN_HFT_2023241.Models; +using System.ComponentModel; +using System.Windows; +using CommunityToolkit.Mvvm.ComponentModel; +using System.Windows.Input; +using CommunityToolkit.Mvvm.Input; + +namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels +{ + public class GetAllMaintainerTeamsViewModel : ObservableRecipient + { + public RestCollection MaintainerTeams { get; set; } + + private MaintainerTeam selectedMaintainerTeam; + + public MaintainerTeam SelectedMaintainerTeam + { + get { return selectedMaintainerTeam; } + set { SetProperty(ref selectedMaintainerTeam, value); (UpdateMaintainerTeamCommand as RelayCommand).NotifyCanExecuteChanged(); } + } + + public ICommand UpdateMaintainerTeamCommand { get; set; } + + public static bool IsInDesignMode + { + get + { + var prop = DesignerProperties.IsInDesignModeProperty; + return (bool)DependencyPropertyDescriptor.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue; + } + } + + public GetAllMaintainerTeamsViewModel() + { + if (!IsInDesignMode) + { + MaintainerTeams = new RestCollection("http://localhost:5000/", "api/MaintainerTeam", "hub"); + + UpdateMaintainerTeamCommand = new RelayCommand(() => + { + MaintainerTeams.Update(SelectedMaintainerTeam); + }, + () => + { + return SelectedMaintainerTeam != null; + }); + } + } + } +} diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllCustomers.xaml b/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllCustomers.xaml index dc572f4..e1466bc 100644 --- a/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllCustomers.xaml +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllCustomers.xaml @@ -3,60 +3,74 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:local="clr-namespace:WD7UVN_SzTGUI_2023242.Client.WPF.Windows" + xmlns:local="clr-namespace:WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels" mc:Ignorable="d" Title="Customers" Height="550" Width="350"> + + + + + - + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + + + + +