mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-10-06 07:42:09 +00:00
48 lines
1.4 KiB
C#
48 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");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|