Loads of stuff, deletion works, SignalR working

This commit is contained in:
MiskolcziRichard
2024-04-28 18:01:14 +02:00
parent 93983993eb
commit a8123e7c7d
5 changed files with 191 additions and 37 deletions

View File

@@ -21,66 +21,118 @@
<Grid Grid.Column="0">
<Grid.RowDefinitions>
<RowDefinition Height="9*" />
<RowDefinition Height="1*" />
<RowDefinition Height="8*" />
<RowDefinition Height="2*" />
</Grid.RowDefinitions>
<ListBox Grid.Row="0">
<ListBox Grid.Row="0" ItemsSource="{Binding Services}" SelectedItem="{Binding SelectedService}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<Button Content="{Binding NAME}" Margin="5px"/>
<Label Content="{Binding NAME}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Grid.Row="1" Margin="5" Content="Expand all" Click="ExpandAllServices"/>
<UniformGrid Grid.Row="1" Rows="3">
<Button Content="Delete selected" Command="{Binding DeleteServiceCommand}"></Button>
<Button Content="Create new" Command="{Binding CreateServiceCommand}"></Button>
<Button Content="Expand all" Click="ExpandAllServices"/>
</UniformGrid>
</Grid>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="9*" />
<RowDefinition Height="1*" />
<RowDefinition Height="8*" />
<RowDefinition Height="2*" />
</Grid.RowDefinitions>
<ListBox Grid.Row="0">
<ListBox Grid.Row="0" ItemsSource="{Binding Customers}" SelectedItem="{Binding SelectedCustomer}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<Button Content="{Binding NAME}" Margin="5px"/>
<Label Content="{Binding NAME}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Grid.Row="1" Margin="5" Content="Expand all" Click="ExpandAllCustomers" />
<UniformGrid Grid.Row="1" Rows="3">
<Button Content="Delete selected" Command="{Binding DeleteCustomerCommand}"></Button>
<Button Content="Create new" Command="{Binding CreateCustomerCommand}"></Button>
<Button Content="Expand all" Click="ExpandAllCustomers"/>
</UniformGrid>
</Grid>
<Grid Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition Height="9*" />
<RowDefinition Height="1*" />
<RowDefinition Height="8*" />
<RowDefinition Height="2*" />
</Grid.RowDefinitions>
<ListBox Grid.Row="0">
<ListBox Grid.Row="0" ItemsSource="{Binding MaintainerTeams}" SelectedItem="{Binding SelectedMaintainerTeam}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<Button Content="{Binding NAME}" Margin="5px"/>
<Label Content="{Binding NAME}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Grid.Row="1" Margin="5" Content="Expand all" Click="ExpandAllClients" />
<UniformGrid Grid.Row="1" Rows="3">
<Button Content="Delete selected" Command="{Binding DeleteMaintainerTeamCommand}"></Button>
<Button Content="Create new" Command="{Binding CreateMaintainerTeamCommand}"></Button>
<Button Content="Expand all" Click="ExpandAllMaintainerTeams"/>
</UniformGrid>
</Grid>
<Grid Grid.Column="3">
<Grid.RowDefinitions>
<RowDefinition Height="9*" />
<RowDefinition Height="1*" />
<RowDefinition Height="8*" />
<RowDefinition Height="2*" />
</Grid.RowDefinitions>
<ListBox Grid.Row="0">
<ListBox Grid.Row="0" ItemsSource="{Binding Employees}" SelectedItem="{Binding SelectedEmployee}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<Button Content="{Binding NAME}" Margin="5px"/>
<Label Content="{Binding NAME}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Grid.Row="1" Margin="5" Content="Expand all" Click="ExpandAllTeams" />
<UniformGrid Grid.Row="1" Rows="3">
<Button Content="Delete selected" Command="{Binding DeleteEmployeeCommand}"></Button>
<Button Content="Create new" Command="{Binding CreateEmployeeCommand}"></Button>
<Button Content="Expand all" Click="ExpandAllEmployees"/>
</UniformGrid>
</Grid>

View File

@@ -23,12 +23,12 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF
}
private void ExpandAllClients(object sender, RoutedEventArgs e)
private void ExpandAllEmployees(object sender, RoutedEventArgs e)
{
}
private void ExpandAllTeams(object sender, RoutedEventArgs e)
private void ExpandAllMaintainerTeams(object sender, RoutedEventArgs e)
{
}

View File

@@ -183,7 +183,7 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF
public async Task DeleteAsync(int id, string endpoint)
{
HttpResponseMessage response =
await client.DeleteAsync(endpoint + "/" + id.ToString());
await client.DeleteAsync("api/" + endpoint + "/" + id.ToString());
if (!response.IsSuccessStatusCode)
{

View File

@@ -2,24 +2,48 @@
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 MainWindowViewModel : ObservableRecipient
{
private string errorMessage;
public string ErrorMessage
{
get { return errorMessage; }
set { SetProperty(ref errorMessage, value); }
}
public RestCollection<Service> Services { get; set; }
public RestCollection<MaintainerTeam> MaintainerTeams { get; set; }
public RestCollection<Customer> Customers { get; set; }
public RestCollection<Employee> Employees { get; set; }
private Service selectedService;
public Service SelectedService
{
get { return selectedService; }
set { SetProperty(ref selectedService, value); (DeleteServiceCommand as RelayCommand).NotifyCanExecuteChanged(); }
}
private Employee selectedEmployee;
public Employee SelectedEmployee
{
get { return selectedEmployee; }
set { SetProperty(ref selectedEmployee, value); (DeleteEmployeeCommand as RelayCommand).NotifyCanExecuteChanged(); }
}
private Customer selectedCustomer;
public Customer SelectedCustomer
{
get { return selectedCustomer; }
set { SetProperty(ref selectedCustomer, value); (DeleteCustomerCommand as RelayCommand).NotifyCanExecuteChanged(); }
}
private MaintainerTeam selectedMaintainerTeam;
public MaintainerTeam SelectedMaintainerTeam
{
get { return selectedMaintainerTeam; }
set { SetProperty(ref selectedMaintainerTeam, value); (DeleteMaintainerTeamCommand as RelayCommand).NotifyCanExecuteChanged(); }
}
public ICommand DeleteServiceCommand { get; set; }
public ICommand DeleteCustomerCommand { get; set; }
public ICommand DeleteMaintainerTeamCommand { get; set; }
public ICommand DeleteEmployeeCommand { get; set; }
public static bool IsInDesignMode
{
get
@@ -33,10 +57,46 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels
{
if (!IsInDesignMode)
{
Services = new RestCollection<Service>("http://localhost:5000/", "api/Service");
Employees = new RestCollection<Employee>("http://localhost:5000/", "api/Employee");
MaintainerTeams = new RestCollection<MaintainerTeam>("http://localhost:5000/", "api/MaintainerTeam");
Customers = new RestCollection<Customer>("http://localhost:5000/", "api/Customer");
Services = new RestCollection<Service>("http://localhost:5000/", "api/Service", "hub");
Employees = new RestCollection<Employee>("http://localhost:5000/", "api/Employee", "hub");
MaintainerTeams = new RestCollection<MaintainerTeam>("http://localhost:5000/", "api/MaintainerTeam", "hub");
Customers = new RestCollection<Customer>("http://localhost:5000/", "api/Customer", "hub");
DeleteServiceCommand = new RelayCommand(() =>
{
Services.Delete(SelectedService.ID);
},
() =>
{
return SelectedService != null;
});
DeleteCustomerCommand = new RelayCommand(() =>
{
Customers.Delete(SelectedCustomer.ID);
},
() =>
{
return SelectedCustomer != null;
});
DeleteEmployeeCommand = new RelayCommand(() =>
{
Employees.Delete(SelectedEmployee.ID);
},
() =>
{
return SelectedEmployee != null;
});
DeleteMaintainerTeamCommand = new RelayCommand(() =>
{
MaintainerTeams.Delete(SelectedMaintainerTeam.ID);
},
() =>
{
return SelectedMaintainerTeam != null;
});
}
}
}

View File

@@ -7,12 +7,54 @@
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Compile Update="Windows\GetAllServices.xaml.cs">
<Compile Update="Windows\Create\CreateNewCustomer.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\Create\CreateNewEmployee.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\Create\CreateNewMaintainerTeam.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\Create\CreateNewService.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\GetAll\GetAllCustomers.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\GetAll\GetAllEmployees.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\GetAll\GetAllMaintainerTeams.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\GetAll\GetAllServices.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Page Update="Windows\GetAllServices.xaml">
<Page Update="Windows\Create\CreateNewCustomer.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\Create\CreateNewEmployee.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\Create\CreateNewMaintainerTeam.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\Create\CreateNewService.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\GetAll\GetAllCustomers.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\GetAll\GetAllEmployees.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\GetAll\GetAllMaintainerTeams.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\GetAll\GetAllServices.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="MainWindow.xaml">