From 4bffe135790cf91e5d6d156ec0a65334f3481cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miskolczi=20Rich=C3=A1rd?= Date: Mon, 29 Apr 2024 22:57:48 +0200 Subject: [PATCH] GetAll windows done --- .../MainWindow.xaml.cs | 10 +- .../ViewModels/GetAllCustomersViewModel.cs | 50 +++++++++ .../ViewModels/GetAllEmployeesViewModel.cs | 50 +++++++++ .../GetAllMaintainerTeamsViewModel.cs | 50 +++++++++ .../Windows/GetAll/GetAllCustomers.xaml | 96 ++++++++++------- .../Windows/GetAll/GetAllCustomers.xaml.cs | 20 ++-- .../Windows/GetAll/GetAllEmployees.xaml | 100 +++++++++++------- .../Windows/GetAll/GetAllEmployees.xaml.cs | 6 ++ .../Windows/GetAll/GetAllMaintainerTeams.xaml | 96 +++++++++-------- .../GetAll/GetAllMaintainerTeams.xaml.cs | 20 ++-- .../Windows/GetAll/GetAllServices.xaml | 2 +- .../Windows/GetAll/GetAllServices.xaml.cs | 4 +- 12 files changed, 346 insertions(+), 158 deletions(-) create mode 100644 WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllCustomersViewModel.cs create mode 100644 WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllEmployeesViewModel.cs create mode 100644 WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllMaintainerTeamsViewModel.cs diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml.cs index 6bcccf7..e94c515 100644 --- a/WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml.cs +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml.cs @@ -1,4 +1,5 @@ using System.Windows; +using WD7UVN_SzTGUI_2023242.Client.WPF.Windows; namespace WD7UVN_SzTGUI_2023242.Client.WPF { @@ -20,17 +21,20 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF private void ExpandAllCustomers(object sender, RoutedEventArgs e) { - + Window window = new GetAllCustomers(); + window.Show(); } private void ExpandAllEmployees(object sender, RoutedEventArgs e) { - + Window window = new GetAllEmployees(); + window.Show(); } private void ExpandAllMaintainerTeams(object sender, RoutedEventArgs e) { - + Window window = new GetAllMaintainerTeams(); + window.Show(); } } } diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllCustomersViewModel.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllCustomersViewModel.cs new file mode 100644 index 0000000..b3f6872 --- /dev/null +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllCustomersViewModel.cs @@ -0,0 +1,50 @@ +using WD7UVN_HFT_2023241.Models; +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 GetAllCustomersViewModel : ObservableRecipient + { + public RestCollection Customers { get; set; } + + private Customer selectedCustomer; + + public Customer SelectedCustomer + { + get { return selectedCustomer; } + set { SetProperty(ref selectedCustomer, value); (UpdateCustomerCommand as RelayCommand).NotifyCanExecuteChanged(); } + } + + public ICommand UpdateCustomerCommand { get; set; } + + public static bool IsInDesignMode + { + get + { + var prop = DesignerProperties.IsInDesignModeProperty; + return (bool)DependencyPropertyDescriptor.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue; + } + } + + public GetAllCustomersViewModel() + { + if (!IsInDesignMode) + { + Customers = new RestCollection("http://localhost:5000/", "api/Customer", "hub"); + + UpdateCustomerCommand = new RelayCommand(() => + { + Customers.Update(SelectedCustomer); + }, + () => + { + return SelectedCustomer != null; + }); + } + } + } +} diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllEmployeesViewModel.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllEmployeesViewModel.cs new file mode 100644 index 0000000..8361f9c --- /dev/null +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllEmployeesViewModel.cs @@ -0,0 +1,50 @@ +using WD7UVN_HFT_2023241.Models; +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 GetAllEmployeesViewModel : ObservableRecipient + { + public RestCollection Employees { get; set; } + + private Employee selectedEmployee; + + public Employee SelectedEmployee + { + get { return selectedEmployee; } + set { SetProperty(ref selectedEmployee, value); (UpdateEmployeeCommand as RelayCommand).NotifyCanExecuteChanged(); } + } + + public ICommand UpdateEmployeeCommand { get; set; } + + public static bool IsInDesignMode + { + get + { + var prop = DesignerProperties.IsInDesignModeProperty; + return (bool)DependencyPropertyDescriptor.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue; + } + } + + public GetAllEmployeesViewModel() + { + if (!IsInDesignMode) + { + Employees = new RestCollection("http://localhost:5000/", "api/Employee", "hub"); + + UpdateEmployeeCommand = new RelayCommand(() => + { + Employees.Update(SelectedEmployee); + }, + () => + { + return SelectedEmployee != null; + }); + } + } + } +} diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllMaintainerTeamsViewModel.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllMaintainerTeamsViewModel.cs new file mode 100644 index 0000000..f0fd541 --- /dev/null +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllMaintainerTeamsViewModel.cs @@ -0,0 +1,50 @@ +using WD7UVN_HFT_2023241.Models; +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 GetAllMaintainerTeamsViewModel : ObservableRecipient + { + public RestCollection MaintainerTeams { get; set; } + + private MaintainerTeam selectedMaintainerTeam; + + public MaintainerTeam SelectedMaintainerTeam + { + get { return selectedMaintainerTeam; } + set { SetProperty(ref selectedMaintainerTeam, value); (UpdateMaintainerTeamCommand as RelayCommand).NotifyCanExecuteChanged(); } + } + + public ICommand UpdateMaintainerTeamCommand { get; set; } + + public static bool IsInDesignMode + { + get + { + var prop = DesignerProperties.IsInDesignModeProperty; + return (bool)DependencyPropertyDescriptor.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue; + } + } + + public GetAllMaintainerTeamsViewModel() + { + if (!IsInDesignMode) + { + MaintainerTeams = new RestCollection("http://localhost:5000/", "api/MaintainerTeam", "hub"); + + UpdateMaintainerTeamCommand = new RelayCommand(() => + { + MaintainerTeams.Update(SelectedMaintainerTeam); + }, + () => + { + return SelectedMaintainerTeam != null; + }); + } + } + } +} diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllCustomers.xaml b/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllCustomers.xaml index dc572f4..e1466bc 100644 --- a/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllCustomers.xaml +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/GetAll/GetAllCustomers.xaml @@ -3,60 +3,74 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:local="clr-namespace:WD7UVN_SzTGUI_2023242.Client.WPF.Windows" + xmlns:local="clr-namespace:WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels" mc:Ignorable="d" Title="Customers" Height="550" Width="350"> + + + + + - + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + + + + +