using MMOserver.RDB.Models; using MMOserver.RDB.Repositories; namespace MMOserver.RDB.Services; public class TestService { private readonly TestRepository repo; public TestService(TestRepository repo) { this.repo = repo; } public Task GetTestAsync(int id) { return repo.GetByIdAsync(id); } public Task GetTestByUuidAsync(string uuid) { return repo.GetByUuidAsync(uuid); } public Task> GetAllTestsAsync() { return repo.GetAllAsync(); } public async Task CreateTestAsync(int testA, string testB, double testC) { if (string.IsNullOrWhiteSpace(testB)) { throw new ArgumentException("TestB is required"); } return await repo.InsertAsync(new Test { TestA = testA, TestB = testB, TestC = testC, Uuid = Guid.NewGuid().ToString() }); } public async Task UpdateTestAsync(int id, int? testA, string? testB, double? testC) { Test entity = await repo.GetByIdAsync(id) ?? throw new KeyNotFoundException("Test not found"); entity.TestA = testA ?? entity.TestA; entity.TestB = testB ?? entity.TestB; entity.TestC = testC ?? entity.TestC; return await repo.UpdateAsync(entity); } public async Task DeleteTestAsync(int id) { Test entity = await repo.GetByIdAsync(id) ?? throw new KeyNotFoundException("Test not found"); return await repo.DeleteAsync(entity); } }