mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-10-02 17:53:20 +00:00
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.
47 lines
1.4 KiB
C#
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");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|