First Server Test | Next Update: Change Commands to Attributes

This commit is contained in:
SnapixLP | Tim G.
2025-06-05 08:27:40 +02:00
parent 67bfce265c
commit 4be4ee34cb
12 changed files with 148 additions and 26 deletions

View File

@@ -69,8 +69,8 @@ public class Server
// Create the JSON request
var request = new JsonRequest
{
Id = requestId,
Command = command
cmd = command,
cid = requestId
};
string jsonString = JsonSerializer.Serialize(request);
@@ -92,8 +92,8 @@ public class Server
private class JsonRequest
{
public string Id { get; set; }
public string Command { get; set; }
public string cmd { get; set; }
public string cid { get; set; }
}
private class JsonResponse
@@ -119,9 +119,9 @@ public class Server
// Implement logic to get a worker by ID or code
if (id != null)
commandResult = ExecuteCommandAsync(".get worker byid " + id).Result;
commandResult = ExecuteCommandAsync("get worker byid " + id).Result;
else
commandResult = ExecuteCommandAsync(".get worker bycode " + id).Result;
commandResult = ExecuteCommandAsync("get worker bycode " + id).Result;
// Deserialize the command result to an Employee object
try
@@ -140,7 +140,7 @@ public class Server
public Task<string> Login(string username, string password)
{
// Implement login logic
var commandResult = ExecuteCommandAsync(".login " + username + " " + password).Result;
var commandResult = ExecuteCommandAsync("login " + username + " " + password).Result;
if (commandResult == "success")
{
return Task.FromResult("Success");
@@ -151,7 +151,7 @@ public class Server
public Task<string> Logout()
{
// Implement logout logic
var commandResult = ExecuteCommandAsync(".logout").Result;
var commandResult = ExecuteCommandAsync("logout").Result;
if (commandResult == "success")
{
return Task.FromResult("Success");
@@ -161,7 +161,7 @@ public class Server
public Task<string> clockIn(Employee employee)
{
var commandResult = ExecuteCommandAsync(".clockin ").Result;
var commandResult = ExecuteCommandAsync("clock in").Result;
if (commandResult == "success")
{
return Task.FromResult("Success");
@@ -170,7 +170,7 @@ public class Server
}
public Task<string> clockOut(Employee employee)
{
var commandResult = ExecuteCommandAsync(".clockout ").Result;
var commandResult = ExecuteCommandAsync("clock out").Result;
if (commandResult == "success")
{
return Task.FromResult("Success");
@@ -182,7 +182,7 @@ public class Server
}
public Task<string> clockBreak(Employee employee)
{
var commandResult = ExecuteCommandAsync(".clockbreak").Result;
var commandResult = ExecuteCommandAsync("clock break").Result;
if (commandResult == "success")
{
return Task.FromResult("Success");