From 0f93e5fd259f5e1382b7f34b86c80da5e989ebb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miskolczi=20Rich=C3=A1rd?= Date: Sun, 5 May 2024 17:11:35 +0200 Subject: [PATCH] WhoMaintainsService done --- .../WhoMaintainsServiceController.cs | 2 +- .../ViewModels/GetAllServicesViewModel.cs | 12 ++++ .../ViewModels/GetMaintainersViewModel.cs | 29 ++++++++ ...7UVN_SzTGUI_2023242.Client.WPF.csproj.user | 6 ++ .../Windows/GetAll/GetAllServices.xaml | 3 +- .../Windows/NonCRUD/GetMaintainers.xaml | 67 +++++++++++++++++++ .../Windows/NonCRUD/GetMaintainers.xaml.cs | 20 ++++++ 7 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetMaintainersViewModel.cs create mode 100644 WD7UVN_SzTGUI_2023242.Client.WPF/Windows/NonCRUD/GetMaintainers.xaml create mode 100644 WD7UVN_SzTGUI_2023242.Client.WPF/Windows/NonCRUD/GetMaintainers.xaml.cs diff --git a/WD7UVN_HFT_2023241.Endpoint/Controllers/WhoMaintainsServiceController.cs b/WD7UVN_HFT_2023241.Endpoint/Controllers/WhoMaintainsServiceController.cs index f393d92..c5bfb21 100644 --- a/WD7UVN_HFT_2023241.Endpoint/Controllers/WhoMaintainsServiceController.cs +++ b/WD7UVN_HFT_2023241.Endpoint/Controllers/WhoMaintainsServiceController.cs @@ -18,7 +18,7 @@ namespace WD7UVN_HFT_2023241.Endpoint } [HttpGet()] - public IQueryable? WhoUsesService([FromQuery] int id) + public IQueryable? WhoMaintainsService([FromQuery] int id) { try { diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllServicesViewModel.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllServicesViewModel.cs index cf90e93..8a9c553 100644 --- a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllServicesViewModel.cs +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllServicesViewModel.cs @@ -23,12 +23,14 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels (UpdateServiceCommand as RelayCommand).NotifyCanExecuteChanged(); (DeleteServiceCommand as RelayCommand).NotifyCanExecuteChanged(); (GetResponsibleEmployeeCommand as RelayCommand).NotifyCanExecuteChanged(); + (GetMaintainersCommand as RelayCommand).NotifyCanExecuteChanged(); } } public ICommand UpdateServiceCommand { get; set; } public ICommand DeleteServiceCommand { get; set; } public ICommand GetResponsibleEmployeeCommand { get; set; } + public ICommand GetMaintainersCommand { get; set; } public static bool IsInDesignMode { @@ -72,6 +74,16 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels { return SelectedService != null; }); + + GetMaintainersCommand = new RelayCommand(() => + { + Window window = new GetMaintainers(SelectedService); + window.Show(); + }, + () => + { + return SelectedService != null; + }); } } } diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetMaintainersViewModel.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetMaintainersViewModel.cs new file mode 100644 index 0000000..59048f0 --- /dev/null +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetMaintainersViewModel.cs @@ -0,0 +1,29 @@ +using WD7UVN_HFT_2023241.Models; +using System.ComponentModel; +using System.Windows; +using CommunityToolkit.Mvvm.ComponentModel; + +namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels +{ + public class GetMaintainersViewModel : ObservableRecipient + { + public RestCollection Employees { get; set; } + + public static bool IsInDesignMode + { + get + { + var prop = DesignerProperties.IsInDesignModeProperty; + return (bool)DependencyPropertyDescriptor.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue; + } + } + + public GetMaintainersViewModel(Service e) + { + if (!IsInDesignMode) + { + Employees = new RestCollection("http://localhost:5000/", "api/WhoMaintainsService?id=" + e.ID.ToString(), "hub", true); + } + } + } +} diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/WD7UVN_SzTGUI_2023242.Client.WPF.csproj.user b/WD7UVN_SzTGUI_2023242.Client.WPF/WD7UVN_SzTGUI_2023242.Client.WPF.csproj.user index 6b5cfb7..d7b9424 100644 --- a/WD7UVN_SzTGUI_2023242.Client.WPF/WD7UVN_SzTGUI_2023242.Client.WPF.csproj.user +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/WD7UVN_SzTGUI_2023242.Client.WPF.csproj.user @@ -31,6 +31,9 @@ Code + + Code + Code @@ -63,6 +66,9 @@ Designer + + Designer + Designer diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllServices.xaml b/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllServices.xaml index 958bc22..3c8e580 100644 --- a/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllServices.xaml +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllServices.xaml @@ -84,11 +84,12 @@ - +