shoc-backend/SeaHaven.Services/Helpers/WorkOrderUpliftEvidenceAssociation.cs
Arthur Bassi 2f4b783615 fix(uplifts): open evidence by work-order access and keep every file
Auto-approved evidence was hidden because download checked the approval tier. Viewers of the work order can open it, and a request can store more than one scanned document.
2026-09-28 16:24:26 -03:00

47 lines
1.4 KiB
C#

using SeaHaven.DataServices.Interfaces;
namespace SeaHaven.Services.Helpers
{
public static class WorkOrderUpliftEvidenceAssociation
{
public static IReadOnlyList<int> Normalize(int? single, IEnumerable<int>? many)
{
var ids = new List<int>();
if (single is int one && one > 0)
ids.Add(one);
if (many == null)
return ids;
foreach (var id in many)
{
if (id > 0 && !ids.Contains(id))
ids.Add(id);
}
return ids;
}
public static async Task RequirePassedAsync(
IVendorDocumentDataService documents,
IReadOnlyList<int> documentIds,
int dispatchId,
int vendorId,
CancellationToken cancellationToken)
{
foreach (var documentId in documentIds)
{
var evidence = await documents.GetUpliftEvidenceAsync(
documentId,
dispatchId,
vendorId,
cancellationToken);
if (evidence == null)
{
throw new InvalidOperationException(
"The selected evidence document is not available or has not passed scanning");
}
}
}
}
}