refactor(dotnet): normalize workspace and approval inputs
Validators (Pushes and Pull Requests) / validate-ui-and-storage (push) Successful in 18s
Validators (Pushes and Pull Requests) / validate-core (push) Has been cancelled

This commit is contained in:
2026-07-13 01:29:26 +09:00
parent cb814b8aa2
commit c20cbc982b
3 changed files with 103 additions and 24 deletions
@@ -10,18 +10,39 @@ namespace QuantEngine.Application.Services
{
private readonly IWorkspaceRepository _repository;
public ApprovalService(IWorkspaceRepository repository)
public ApprovalService(IWorkspaceRepository repository)
{
_repository = repository;
}
public Task<IEnumerable<WorkspaceApproval>> GetApprovalsAsync() => _repository.GetApprovalsAsync();
public Task<WorkspaceApproval?> GetApprovalAsync(string domain, string targetRef)
=> _repository.GetApprovalAsync(RequireValue(domain, nameof(domain)), RequireValue(targetRef, nameof(targetRef)));
public Task<bool> UpsertApprovalAsync(WorkspaceApproval approval)
{
ArgumentNullException.ThrowIfNull(approval);
return _repository.UpsertApprovalAsync(approval);
}
public Task<IEnumerable<WorkspaceLock>> GetLocksAsync() => _repository.GetLocksAsync();
public Task<WorkspaceLock?> GetLockAsync(string domain, string targetRef)
=> _repository.GetLockAsync(RequireValue(domain, nameof(domain)), RequireValue(targetRef, nameof(targetRef)));
public Task<bool> AcquireLockAsync(WorkspaceLock @lock)
{
ArgumentNullException.ThrowIfNull(@lock);
return _repository.AcquireLockAsync(@lock);
}
public Task<bool> ReleaseLockAsync(string domain, string targetRef)
=> _repository.ReleaseLockAsync(RequireValue(domain, nameof(domain)), RequireValue(targetRef, nameof(targetRef)));
private static string RequireValue(string value, string parameterName)
{
if (string.IsNullOrWhiteSpace(value))
{
_repository = repository;
throw new ArgumentException("Value is required.", parameterName);
}
public Task<IEnumerable<WorkspaceApproval>> GetApprovalsAsync() => _repository.GetApprovalsAsync();
public Task<WorkspaceApproval?> GetApprovalAsync(string domain, string targetRef) => _repository.GetApprovalAsync(domain, targetRef);
public Task<bool> UpsertApprovalAsync(WorkspaceApproval approval) => _repository.UpsertApprovalAsync(approval);
public Task<IEnumerable<WorkspaceLock>> GetLocksAsync() => _repository.GetLocksAsync();
public Task<WorkspaceLock?> GetLockAsync(string domain, string targetRef) => _repository.GetLockAsync(domain, targetRef);
public Task<bool> AcquireLockAsync(WorkspaceLock @lock) => _repository.AcquireLockAsync(@lock);
public Task<bool> ReleaseLockAsync(string domain, string targetRef) => _repository.ReleaseLockAsync(domain, targetRef);
return value.Trim();
}
}
}