From 04f7e998cb0b99954caa7e26c628f0b9fb5eaddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miskolczi=20Rich=C3=A1rd?= Date: Sun, 5 May 2024 18:14:31 +0200 Subject: [PATCH] Adding Customers now works. --- .../TUI/Properties/launchSettings.json | 8 +++ .../ViewModels/CreateNewCustomerViewModel.cs | 56 ++++++++++++++++ .../GetAllMaintainerTeamsViewModel.cs | 19 +++++- .../ViewModels/GetColleaguesViewModel.cs | 29 ++++++++ ...7UVN_SzTGUI_2023242.Client.WPF.csproj.user | 6 ++ .../Windows/Create/CreateNewCustomer.xaml | 57 +++++++++++++++- .../Windows/Create/CreateNewCustomer.xaml.cs | 20 ++---- .../Windows/GetAll/GetAllCustomers.xaml.cs | 15 ++++- .../Windows/GetAll/GetAllMaintainerTeams.xaml | 7 +- .../Windows/NonCRUD/GetColleagues.xaml | 67 +++++++++++++++++++ .../Windows/NonCRUD/GetColleagues.xaml.cs | 17 +++++ .../Windows/NonCRUD/GetSubordinates.xaml.cs | 3 - 12 files changed, 279 insertions(+), 25 deletions(-) create mode 100644 WD7UVN_HFT_2023241.Client/TUI/Properties/launchSettings.json create mode 100644 WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/CreateNewCustomerViewModel.cs create mode 100644 WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetColleaguesViewModel.cs create mode 100644 WD7UVN_SzTGUI_2023242.Client.WPF/Windows/NonCRUD/GetColleagues.xaml create mode 100644 WD7UVN_SzTGUI_2023242.Client.WPF/Windows/NonCRUD/GetColleagues.xaml.cs diff --git a/WD7UVN_HFT_2023241.Client/TUI/Properties/launchSettings.json b/WD7UVN_HFT_2023241.Client/TUI/Properties/launchSettings.json new file mode 100644 index 0000000..33504c9 --- /dev/null +++ b/WD7UVN_HFT_2023241.Client/TUI/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "WSL": { + "commandName": "WSL2", + "distributionName": "" + } + } +} \ No newline at end of file diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/CreateNewCustomerViewModel.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/CreateNewCustomerViewModel.cs new file mode 100644 index 0000000..3de889f --- /dev/null +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/CreateNewCustomerViewModel.cs @@ -0,0 +1,56 @@ +using WD7UVN_HFT_2023241.Models; +using System.ComponentModel; +using System.Windows; +using CommunityToolkit.Mvvm.ComponentModel; +using System.Windows.Input; +using CommunityToolkit.Mvvm.Input; +using System; + +namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels +{ + public class CreateNewCustomerViewModel : ObservableRecipient + { + public Action CloseAction { get; set; } + public event Action NewCustomerCreated; + + public Customer newCustomer; + public Customer NewCustomer + { + get { return newCustomer; } + set + { + SetProperty(ref newCustomer, value); + (CreateCommand as RelayCommand).NotifyCanExecuteChanged(); + } + } + + public ICommand CreateCommand { get; set; } + + public static bool IsInDesignMode + { + get + { + var prop = DesignerProperties.IsInDesignModeProperty; + return (bool)DependencyPropertyDescriptor.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue; + } + } + + public CreateNewCustomerViewModel() + { + newCustomer = new Customer(); + + if (!IsInDesignMode) + { + CreateCommand = new RelayCommand(() => + { + NewCustomerCreated?.Invoke(NewCustomer); + CloseAction(); + }, + () => + { + return NewCustomer != null; + }); + } + } + } +} diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllMaintainerTeamsViewModel.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllMaintainerTeamsViewModel.cs index f0fd541..2e85bec 100644 --- a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllMaintainerTeamsViewModel.cs +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetAllMaintainerTeamsViewModel.cs @@ -4,6 +4,7 @@ using System.Windows; using CommunityToolkit.Mvvm.ComponentModel; using System.Windows.Input; using CommunityToolkit.Mvvm.Input; +using WD7UVN_SzTGUI_2023242.Client.WPF.Windows; namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels { @@ -16,10 +17,16 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels public MaintainerTeam SelectedMaintainerTeam { get { return selectedMaintainerTeam; } - set { SetProperty(ref selectedMaintainerTeam, value); (UpdateMaintainerTeamCommand as RelayCommand).NotifyCanExecuteChanged(); } + set + { + SetProperty(ref selectedMaintainerTeam, value); + (UpdateMaintainerTeamCommand as RelayCommand).NotifyCanExecuteChanged(); + (GetColleaguesCommand as RelayCommand).NotifyCanExecuteChanged(); + } } public ICommand UpdateMaintainerTeamCommand { get; set; } + public ICommand GetColleaguesCommand { get; set; } public static bool IsInDesignMode { @@ -44,6 +51,16 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels { return SelectedMaintainerTeam != null; }); + + GetColleaguesCommand = new RelayCommand(() => + { + Window window = new GetColleagues(SelectedMaintainerTeam); + window.Show(); + }, + () => + { + return SelectedMaintainerTeam != null; + }); } } } diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetColleaguesViewModel.cs b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetColleaguesViewModel.cs new file mode 100644 index 0000000..dd52208 --- /dev/null +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/ViewModels/GetColleaguesViewModel.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 GetColleaguesViewModel : 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 GetColleaguesViewModel(MaintainerTeam e) + { + if (!IsInDesignMode) + { + Employees = new RestCollection("http://localhost:5000/", "api/WhoWorksInMaintainerTeam?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 fd09240..e5ddae1 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 @@ -69,6 +72,9 @@ Designer + + Designer + Designer diff --git a/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/Create/CreateNewCustomer.xaml b/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/Create/CreateNewCustomer.xaml index bdb6e2f..6fce736 100644 --- a/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/Create/CreateNewCustomer.xaml +++ b/WD7UVN_SzTGUI_2023242.Client.WPF/Windows/Create/CreateNewCustomer.xaml @@ -5,8 +5,61 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:WD7UVN_SzTGUI_2023242.Client.WPF.Windows" mc:Ignorable="d" - Title="CreateNewCustomer" Height="450" Width="800"> + Title="CreateNewCustomer" Height="550" Width="350"> + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +