noncrud db calls now work

This commit is contained in:
MiskolcziRichard
2024-05-04 20:07:46 +02:00
parent a44c44d671
commit 3c597bc4d3
2 changed files with 17 additions and 3 deletions

View File

@@ -285,7 +285,7 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF
bool hasSignalR;
Type type = typeof(T);
public RestCollection(string baseurl, string endpoint, string hub = null)
public RestCollection(string baseurl, string endpoint, string hub = null, bool nonCrud = false)
{
hasSignalR = hub != null;
this.rest = new RestService(baseurl, endpoint);
@@ -318,7 +318,21 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF
this.notify.Init();
}
Init();
if (!nonCrud)
{
Init();
}
else
{
InitCustomEndpoint(endpoint);
}
}
private async Task InitCustomEndpoint(string endpoint)
{
items = await rest.GetAsync<T>(endpoint);
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
private async Task Init()

View File

@@ -42,7 +42,7 @@ namespace WD7UVN_SzTGUI_2023242.Client.WPF.ViewModels
{
if (!IsInDesignMode)
{
Employees = new RestCollection<Employee>("http://localhost:5000/", "api/GetSubordinates?id=" + e.ID.ToString(), "hub");
Employees = new RestCollection<Employee>("http://localhost:5000/", "api/GetSubordinates?id=" + e.ID.ToString(), "hub", true);
UpdateEmployeeCommand = new RelayCommand(() =>
{