using System.Text.Json; using GB5Shared.DTO.Framework.Login; using WiDAL.CustomCode.WiWorkOrder; namespace WiBLL.WiWorkOrder; public class WiWorkOrderBLL : IWiWorkOrderBLL { private readonly IWiWorkOrderDAL _dal; public WiWorkOrderBLL(IWiWorkOrderDAL dal) => _dal = dal; public async Task ValidateWorkOrderExists(int indentDetailId, LoginDTO login, CancellationToken ct) { var wo = await _dal.GetWorkOrderDetail(indentDetailId, login, ct).ConfigureAwait(false); return wo is not null; } public async Task ResolveWorkstationsForWorkOrder(int indentDetailId, LoginDTO login, CancellationToken ct) { var wo = await _dal.GetWorkOrderDetail(indentDetailId, login, ct).ConfigureAwait(false) ?? throw new InvalidOperationException($"Work order detail {indentDetailId} not found."); var candidates = await _dal.ResolveWorkstationsForWorkOrder(wo, login, ct).ConfigureAwait(false); return JsonSerializer.Serialize(candidates); } public async Task GetWorkOrderGroup(int combineIndentId, LoginDTO login, CancellationToken ct) { var group = await _dal.GetWorkOrderGroup(combineIndentId, login, ct).ConfigureAwait(false); return JsonSerializer.Serialize(group); } }