mirror of
https://git.battle-of-pip.de/root/vpr-mitarbeiterverwaltung.git
synced 2025-12-13 22:31:38 +01:00
Fixed some Server bugs where the Employee is not send as full object
This commit is contained in:
@@ -117,7 +117,7 @@ public class Server
|
||||
public string Response { get; set; }
|
||||
}
|
||||
|
||||
public Task<Employee?> GetEmployee(int? id = null, string code = null)
|
||||
public Task<Employee> GetEmployee(int? id = null, string code = null)
|
||||
{
|
||||
if (id == null && code == null)
|
||||
{
|
||||
@@ -128,8 +128,6 @@ public class Server
|
||||
{
|
||||
throw new ArgumentException("Only one of id or code should be provided.");
|
||||
}
|
||||
|
||||
Employee? employee = null;
|
||||
string commandResult;
|
||||
|
||||
// Implement logic to get a worker by ID or code
|
||||
@@ -141,15 +139,14 @@ public class Server
|
||||
// Deserialize the command result to an Employee object
|
||||
try
|
||||
{
|
||||
employee = JsonSerializer.Deserialize<Employee>(commandResult);
|
||||
return Task.FromResult(employee);
|
||||
return Task.FromResult(Employee.FromJson(commandResult));
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
Console.WriteLine("Failed to deserialize the command result.");
|
||||
}
|
||||
|
||||
return Task.FromException<Employee?>(new Exception("Failed to get worker."));
|
||||
return Task.FromException<Employee>(new Exception("Failed to get worker."));
|
||||
}
|
||||
|
||||
public Task<string> Login(string username, string password)
|
||||
@@ -182,7 +179,7 @@ public class Server
|
||||
var commandResult = ExecuteCommandAsync("getSelfUser").Result;
|
||||
try
|
||||
{
|
||||
var employee = JsonSerializer.Deserialize<Employee>(commandResult);
|
||||
var employee = Employee.FromJson(commandResult);
|
||||
if (employee != null)
|
||||
{
|
||||
return Task.FromResult(employee);
|
||||
|
||||
Reference in New Issue
Block a user