GetSubordinates done
This commit is contained in:
@@ -11,24 +11,6 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels
|
||||
{
|
||||
public RestCollection<Employee> Employees { get; set; }
|
||||
|
||||
private Employee selectedEmployee;
|
||||
|
||||
public Employee SelectedEmployee
|
||||
{
|
||||
get { return selectedEmployee; }
|
||||
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
|
||||
{
|
||||
get
|
||||
@@ -43,24 +25,6 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels
|
||||
if (!IsInDesignMode)
|
||||
{
|
||||
Employees = new RestCollection<Employee>("http://localhost:5000/", "api/GetSubordinates?id=" + e.ID.ToString(), "hub", true);
|
||||
|
||||
UpdateEmployeeCommand = new RelayCommand(() =>
|
||||
{
|
||||
Employees.Update(SelectedEmployee);
|
||||
},
|
||||
() =>
|
||||
{
|
||||
return SelectedEmployee != null;
|
||||
});
|
||||
|
||||
DeleteEmployeeCommand = new RelayCommand(() =>
|
||||
{
|
||||
Employees.Delete(SelectedEmployee.ID);
|
||||
},
|
||||
() =>
|
||||
{
|
||||
return SelectedEmployee != null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,9 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels"
|
||||
mc:Ignorable="d"
|
||||
Title="Employees" Height="550" Width="350">
|
||||
Title="Subordinates of employee" Height="550" Width="350">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="9*" />
|
||||
<RowDefinition Height="1*" />
|
||||
</Grid.RowDefinitions>
|
||||
<ListBox ItemsSource="{Binding Employees}" Grid.Row="0" SelectedItem="{Binding SelectedEmployee}">
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
@@ -67,11 +63,5 @@
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<UniformGrid Rows="3" Grid.Row="1">
|
||||
<Button Content="Edit selected" Command="{Binding UpdateEmployeeCommand}"/>
|
||||
<Button Content="Delete selected" Command="{Binding DeleteEmployeeCommand}"/>
|
||||
<Button Content="Get subordinates"/>
|
||||
</UniformGrid>
|
||||
</Grid>
|
||||
</Window>
|
||||
Reference in New Issue
Block a user