why not be able to delete objects when expanded?
This commit is contained in:
@@ -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<Employee>("http://localhost:5000/", "api/Employee", "hub");
|
||||
Employees = new RestCollection<Employee>("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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@
|
||||
|
||||
<UniformGrid Rows="2" Grid.Row="1">
|
||||
<Button Content="Edit selected" Command="{Binding UpdateEmployeeCommand}"/>
|
||||
<Button Content="Delete selected" Command="{Binding DeleteEmployeeCommand}"/>
|
||||
<Button Content="Get subordinates"/>
|
||||
<Button Content="Create new" Click="CreateNewEmployee" />
|
||||
</UniformGrid>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user