GetSubordinates done

This commit is contained in:
MiskolcziRichard
2024-05-04 20:16:10 +02:00
parent 3c597bc4d3
commit b0ba438336
2 changed files with 1 additions and 47 deletions

View File

@@ -11,24 +11,6 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels
{ {
public RestCollection<Employee> Employees { get; set; } 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 public static bool IsInDesignMode
{ {
get get
@@ -43,24 +25,6 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels
if (!IsInDesignMode) if (!IsInDesignMode)
{ {
Employees = new RestCollection<Employee>("http://localhost:5000/", "api/GetSubordinates?id=" + e.ID.ToString(), "hub", true); 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;
});
} }
} }
} }

View File

@@ -5,13 +5,9 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels" xmlns:local="clr-namespace:WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels"
mc:Ignorable="d" mc:Ignorable="d"
Title="Employees" Height="550" Width="350"> Title="Subordinates of employee" Height="550" Width="350">
<Grid> <Grid>
<Grid.RowDefinitions>
<RowDefinition Height="9*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<ListBox ItemsSource="{Binding Employees}" Grid.Row="0" SelectedItem="{Binding SelectedEmployee}"> <ListBox ItemsSource="{Binding Employees}" Grid.Row="0" SelectedItem="{Binding SelectedEmployee}">
<ListBox.ItemContainerStyle> <ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem"> <Style TargetType="ListBoxItem">
@@ -67,11 +63,5 @@
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </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> </Grid>
</Window> </Window>