diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllEmployeesViewModel.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllEmployeesViewModel.cs index 8361f9c..12b7bc8 100644 --- a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllEmployeesViewModel.cs +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllEmployeesViewModel.cs @@ -16,10 +16,18 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels public Employee SelectedEmployee { get { return selectedEmployee; } - set { SetProperty(ref selectedEmployee, value); (UpdateEmployeeCommand as RelayCommand).NotifyCanExecuteChanged(); } + set + { + SetProperty(ref selectedEmployee, value); + (UpdateEmployeeCommand as RelayCommand).NotifyCanExecuteChanged(); + (DeleteEmployeeCommand as RelayCommand).NotifyCanExecuteChanged(); + (GetSubordinatesCommand as RelayCommand).NotifyCanExecuteChanged(); + } } public ICommand UpdateEmployeeCommand { get; set; } + public ICommand DeleteEmployeeCommand { get; set; } + public ICommand GetSubordinatesCommand { get; set; } public static bool IsInDesignMode { @@ -34,7 +42,7 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels { if (!IsInDesignMode) { - Employees = new RestCollection("http://localhost:5000/", "api/Employee", "hub"); + Employees = new RestCollection("http://localhost:5000/", "api/GetSubordinates", "hub"); UpdateEmployeeCommand = new RelayCommand(() => { @@ -44,6 +52,15 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels { return SelectedEmployee != null; }); + + DeleteEmployeeCommand = new RelayCommand(() => + { + Employees.Delete(SelectedEmployee.ID); + }, + () => + { + return SelectedEmployee != null; + }); } } } diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllEmployees.xaml b/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllEmployees.xaml index f0bebbe..138d94a 100644 --- a/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllEmployees.xaml +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllEmployees.xaml @@ -74,6 +74,8 @@