Adding Customers now works.
This commit is contained in:
@@ -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<Customer> 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Employee> 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<Employee>("http://localhost:5000/", "api/WhoWorksInMaintainerTeam?id=" + e.ID.ToString(), "hub", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user