2024-04-28 18:00:49 +02:00
|
|
|
|
using WD7UVN_HFT_2023241.Models;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Windows;
|
2024-04-29 11:09:54 +02:00
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
2024-05-04 20:33:50 +02:00
|
|
|
|
using WD7UVN_SzTGUI_2023242.Client.WPF.Windows;
|
2024-04-28 18:00:49 +02:00
|
|
|
|
|
|
|
|
|
|
namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels
|
|
|
|
|
|
{
|
2024-04-29 11:09:54 +02:00
|
|
|
|
public class GetAllServicesViewModel : ObservableRecipient
|
2024-04-28 18:00:49 +02:00
|
|
|
|
{
|
|
|
|
|
|
public RestCollection<Service> Services { get; set; }
|
|
|
|
|
|
|
2024-04-29 11:09:54 +02:00
|
|
|
|
private Service selectedService;
|
|
|
|
|
|
|
|
|
|
|
|
public Service SelectedService
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return selectedService; }
|
2024-05-04 20:33:50 +02:00
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref selectedService, value);
|
|
|
|
|
|
(UpdateServiceCommand as RelayCommand).NotifyCanExecuteChanged();
|
|
|
|
|
|
(DeleteServiceCommand as RelayCommand).NotifyCanExecuteChanged();
|
|
|
|
|
|
(GetResponsibleEmployeeCommand as RelayCommand).NotifyCanExecuteChanged();
|
2024-05-05 17:11:35 +02:00
|
|
|
|
(GetMaintainersCommand as RelayCommand).NotifyCanExecuteChanged();
|
2024-05-04 20:33:50 +02:00
|
|
|
|
}
|
2024-04-29 11:09:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ICommand UpdateServiceCommand { get; set; }
|
2024-05-04 20:33:50 +02:00
|
|
|
|
public ICommand DeleteServiceCommand { get; set; }
|
|
|
|
|
|
public ICommand GetResponsibleEmployeeCommand { get; set; }
|
2024-05-05 17:11:35 +02:00
|
|
|
|
public ICommand GetMaintainersCommand { get; set; }
|
2024-04-29 11:09:54 +02:00
|
|
|
|
|
2024-04-28 18:00:49 +02:00
|
|
|
|
public static bool IsInDesignMode
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var prop = DesignerProperties.IsInDesignModeProperty;
|
|
|
|
|
|
return (bool)DependencyPropertyDescriptor.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public GetAllServicesViewModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!IsInDesignMode)
|
|
|
|
|
|
{
|
|
|
|
|
|
Services = new RestCollection<Service>("http://localhost:5000/", "api/Service", "hub");
|
2024-04-29 11:09:54 +02:00
|
|
|
|
|
|
|
|
|
|
UpdateServiceCommand = new RelayCommand(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Services.Update(SelectedService);
|
|
|
|
|
|
},
|
|
|
|
|
|
() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
return SelectedService != null;
|
|
|
|
|
|
});
|
2024-05-04 20:33:50 +02:00
|
|
|
|
|
|
|
|
|
|
DeleteServiceCommand = new RelayCommand(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Services.Delete(SelectedService.ID);
|
|
|
|
|
|
},
|
|
|
|
|
|
() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
return SelectedService != null;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
GetResponsibleEmployeeCommand = new RelayCommand(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Window window = new GetResponsibleEmployee(SelectedService);
|
|
|
|
|
|
window.Show();
|
|
|
|
|
|
},
|
|
|
|
|
|
() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
return SelectedService != null;
|
|
|
|
|
|
});
|
2024-05-05 17:11:35 +02:00
|
|
|
|
|
|
|
|
|
|
GetMaintainersCommand = new RelayCommand(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Window window = new GetMaintainers(SelectedService);
|
|
|
|
|
|
window.Show();
|
|
|
|
|
|
},
|
|
|
|
|
|
() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
return SelectedService != null;
|
|
|
|
|
|
});
|
2024-04-28 18:00:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|