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 GetTestAsync(int id) { try { Test? result = await _testService.GetTestAsync(id); return result is null ? HandlerHelper.Error("Test not found") : HandlerHelper.Success(result); } catch (Exception ex) { return HandlerHelper.Error(ex.Message); } } public async Task GetTestByUuidAsync(string uuid) { try { Test? result = await _testService.GetTestByUuidAsync(uuid); return result is null ? HandlerHelper.Error("Test not found") : HandlerHelper.Success(result); } catch (Exception ex) { return HandlerHelper.Error(ex.Message); } } public async Task GetAllTestsAsync() { try { return HandlerHelper.Success(await _testService.GetAllTestsAsync()); } catch (Exception ex) { return HandlerHelper.Error(ex.Message); } } public async Task CreateTestAsync(int testA, string testB, double testC) { try { return HandlerHelper.Success(await _testService.CreateTestAsync(testA, testB, testC)); } catch (Exception ex) { return HandlerHelper.Error(ex.Message); } } public async Task UpdateTestAsync(int id, int? testA, string? testB, double? testC) { try { return HandlerHelper.Success(await _testService.UpdateTestAsync(id, testA, testB, testC)); } catch (Exception ex) { return HandlerHelper.Error(ex.Message); } } public async Task DeleteTestAsync(int id) { try { return HandlerHelper.Success(await _testService.DeleteTestAsync(id)); } catch (Exception ex) { return HandlerHelper.Error(ex.Message); } } }