using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using MMDAL.CustomCode.MRPRun; using MMDAL.DTO.MRPRun; namespace MMBLL.MRPRun { public class MRPReportBLL : IMRPReportBLL { private readonly IMRPReportDAL _MRPReportDAL; public MRPReportBLL(IMRPReportDAL mrpReportDAL) => _MRPReportDAL = mrpReportDAL; public async Task> GetShortageReport( MRPReportCriteriaDTO criteria, LoginDTO loginDTO, CancellationToken ct) { ValidateRunId(criteria.MrpRunId); return await _MRPReportDAL.GetShortageReport(criteria, loginDTO, ct) .ConfigureAwait(false); } public async Task> GetStageWiseShortageReport( MRPReportCriteriaDTO criteria, LoginDTO loginDTO, CancellationToken ct) { ValidateRunId(criteria.MrpRunId); return await _MRPReportDAL.GetStageWiseShortageReport(criteria, loginDTO, ct) .ConfigureAwait(false); } public async Task> GetMRPWorksheet( MRPReportCriteriaDTO criteria, LoginDTO loginDTO, CancellationToken ct) { ValidateRunId(criteria.MrpRunId); return await _MRPReportDAL.GetMRPWorksheet(criteria, loginDTO, ct) .ConfigureAwait(false); } public async Task> GetPurchaseRequirement( MRPReportCriteriaDTO criteria, LoginDTO loginDTO, CancellationToken ct) { ValidateRunId(criteria.MrpRunId); return await _MRPReportDAL.GetPurchaseRequirement(criteria, loginDTO, ct) .ConfigureAwait(false); } public async Task> GetScheduleReceipt( MRPReportCriteriaDTO criteria, LoginDTO loginDTO, CancellationToken ct) { ValidateRunId(criteria.MrpRunId); return await _MRPReportDAL.GetScheduleReceipt(criteria, loginDTO, ct) .ConfigureAwait(false); } public async Task> GetMRPRunWithActions( MRPReportCriteriaDTO criteria, LoginDTO loginDTO, CancellationToken ct) { ValidateRunId(criteria.MrpRunId); return await _MRPReportDAL.GetMRPRunWithActions(criteria, loginDTO, ct) .ConfigureAwait(false); } public async Task> GetMRPWithDimensionReport( MRPReportCriteriaDTO criteria, LoginDTO loginDTO, CancellationToken ct) { ValidateRunId(criteria.MrpRunId); return await _MRPReportDAL.GetMRPWithDimensionReport(criteria, loginDTO, ct) .ConfigureAwait(false); } public async Task> GetScopedRunComparison( ScopedRunComparisonCriteriaDTO criteria, LoginDTO loginDTO, CancellationToken ct) { if (criteria.MacroRunId <= 0) throw new ArgumentException("MacroRunId is required."); if (criteria.ScopedRunId <= 0) throw new ArgumentException("ScopedRunId is required."); if (criteria.MacroRunId == criteria.ScopedRunId) throw new ArgumentException("MacroRunId and ScopedRunId must be different."); return await _MRPReportDAL.GetScopedRunComparison(criteria, loginDTO, ct) .ConfigureAwait(false); } private static void ValidateRunId(int mrpRunId) { if (mrpRunId == 0) throw new ArgumentException("MrpRunId is required."); } } }