using AccountsDAL.CustomCode.AccountReports.AccountCollectionProjection; using AccountsDAL.DTO.AccountsReports; using AccountsDAL.DTO.Reports; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.Telemetry; namespace AccountsBLL.AccountReports.AccountCollectionProjection { public class AccountCollectionProjectionReportBLL : IAccountCollectionProjectionReportBLL { private const int DEFAULT_MAX_RESULT_CAP = 500; private readonly IAccountCollectionProjectionReportDAL _accountCollectionProjectionReportDAL; private readonly IAccountReportAccessControlBLL _accessControlBLL; public AccountCollectionProjectionReportBLL( IAccountCollectionProjectionReportDAL accountCollectionProjectionReportDAL, IAccountReportAccessControlBLL accessControlBLL) { _accountCollectionProjectionReportDAL = accountCollectionProjectionReportDAL; _accessControlBLL = accessControlBLL; } public async Task GetCollectionProjectionReport( int firstNumber, int maxResult, CriteriaDTO criteriaDTO, List sortBy, int menuId, LoginDTO loginDTO) { try { GB5Trace.Step("parse-criteria-collection-projection", new { firstNumber, maxResult, menuId }); var criteria = AccountReportCriteriaParser.Parse(criteriaDTO, loginDTO); var cappedMaxResult = Math.Min(maxResult, DEFAULT_MAX_RESULT_CAP); await _accessControlBLL.EnforceForAsOnDateAsync(criteria, cappedMaxResult, menuId, loginDTO).ConfigureAwait(false); GB5Trace.Step("query-collection-projection", new { firstNumber, cappedMaxResult }); return await _accountCollectionProjectionReportDAL .GetCollectionProjectionReport(firstNumber, cappedMaxResult, criteria, sortBy, loginDTO) .ConfigureAwait(false); } catch (Exception ex) { GB5Trace.MarkFailed("account-collection-projection-failed", ex); throw; } } } }