49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using MMOserver.RDB.Models;
|
|
using MMOserver.RDB.Services;
|
|
using ServerLib.RDB.Handlers;
|
|
|
|
namespace MMOserver.RDB.Handlers;
|
|
|
|
public class TestHandler
|
|
{
|
|
private readonly TestService _testService;
|
|
|
|
public TestHandler(TestService testService) => _testService = testService;
|
|
|
|
public async Task<string> GetTestAsync(int id)
|
|
{
|
|
Test? result = await _testService.GetTestAsync(id);
|
|
return result is null
|
|
? HandlerHelper.Error("Test not found")
|
|
: HandlerHelper.Success(result);
|
|
}
|
|
|
|
public async Task<string> GetTestByUuidAsync(string uuid)
|
|
{
|
|
Test? result = await _testService.GetTestByUuidAsync(uuid);
|
|
return result is null
|
|
? HandlerHelper.Error("Test not found")
|
|
: HandlerHelper.Success(result);
|
|
}
|
|
|
|
public async Task<string> GetAllTestsAsync()
|
|
{
|
|
return HandlerHelper.Success(await _testService.GetAllTestsAsync());
|
|
}
|
|
|
|
public async Task<string> CreateTestAsync(int testA, string testB, double testC)
|
|
{
|
|
return HandlerHelper.Success(await _testService.CreateTestAsync(testA, testB, testC));
|
|
}
|
|
|
|
public async Task<string> UpdateTestAsync(int id, int? testA, string? testB, double? testC)
|
|
{
|
|
return HandlerHelper.Success(await _testService.UpdateTestAsync(id, testA, testB, testC));
|
|
}
|
|
|
|
public async Task<string> DeleteTestAsync(int id)
|
|
{
|
|
return HandlerHelper.Success(await _testService.DeleteTestAsync(id));
|
|
}
|
|
}
|