Files
QuantEngineByItz/src/dotnet/QuantEngine.Application/Services/ApprovalService.cs
T
kjh2064 c20cbc982b
Validators (Pushes and Pull Requests) / validate-ui-and-storage (push) Successful in 18s
Validators (Pushes and Pull Requests) / validate-core (push) Has been cancelled
refactor(dotnet): normalize workspace and approval inputs
2026-07-13 01:29:26 +09:00

49 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using QuantEngine.Core.Interfaces;
using QuantEngine.Core.Models;
namespace QuantEngine.Application.Services
{
public class ApprovalService
{
private readonly 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))
{
throw new ArgumentException("Value is required.", parameterName);
}
return value.Trim();
}
}
}