using AccountsDAL.CustomCode.AccountReports.AccountLedger; using AccountsDAL.DTO.AccountsReports; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.Telemetry; namespace AccountsBLL.AccountReports.AccountLedger { public class AccountLedgerSummaryBLL : IAccountLedgerSummaryBLL { private const int DEFAULT_MAX_RESULT_CAP = 500; private readonly IAccountLedgerSummaryDAL _accountLedgerSummaryDAL; private readonly IAccountReportAccessControlBLL _accessControlBLL; public AccountLedgerSummaryBLL(IAccountLedgerSummaryDAL accountLedgerSummaryDAL, IAccountReportAccessControlBLL accessControlBLL) { _accountLedgerSummaryDAL = accountLedgerSummaryDAL; _accessControlBLL = accessControlBLL; } public async Task GetAccountLedgerSummaryReport( int firstNumber, int maxResult, CriteriaDTO criteriaDTO, List sortBy, int menuId, LoginDTO loginDTO) { try { GB5Trace.Step("parse-criteria-account-ledger-summary", new { firstNumber, maxResult, menuId }); var criteria = AccountReportCriteriaParser.Parse(criteriaDTO, loginDTO); var cappedMaxResult = Math.Min(maxResult, DEFAULT_MAX_RESULT_CAP); await _accessControlBLL.EnforceAsync(criteria, cappedMaxResult, menuId, loginDTO).ConfigureAwait(false); GB5Trace.Step("query-account-ledger-summary", new { firstNumber, cappedMaxResult }); return await _accountLedgerSummaryDAL .GetAccountLedgerSummaryReport(firstNumber, cappedMaxResult, criteria, sortBy, loginDTO) .ConfigureAwait(false); } catch (Exception ex) { GB5Trace.MarkFailed("account-ledger-summary-failed", ex); throw; } } } }