Files
monorepo/LCU.API.Operations.IncentiveAPI/LCU.API.Internal.Operations.IncentiveApi/Services/MicroApiServices/CoreApiWrapperService.cs
T
2026-03-17 09:53:09 -05:00

188 lines
7.2 KiB
C#

using LCU.API.Internal.Operations.IncentiveApi.Configuration;
using LCU.API.Internal.Operations.IncentiveApi.DataAccess;
using LCU.Library.Internal.IncentiveApiModels.Entities;
using NewAtmCheckCardActivity = LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities.NewAtmCheckCardActivity;
using NewCheckingAccountActivity = LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities.NewCheckingAccountActivity;
using NewLoanSaleActivity = LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities.NewLoanSaleActivity;
using LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Accounts;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Activity;
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Transaction;
using System.Web;
using LCU.Library.Internal.Exceptions;
namespace LCU.API.Internal.Operations.IncentiveApi.Services.MicroApiServices;
public class CoreApiWrapperService : ICoreApiWrapperService
{
private readonly ICoreApiWrapperDao _coreApiWrapperDao;
private readonly CoreApiWrapperConfiguration _coreApiWrapperConfiguration;
public CoreApiWrapperService(CoreApiWrapperConfiguration coreApiWrapperConfiguration, ICoreApiWrapperDao coreApiWrapperDao)
{
_coreApiWrapperDao = coreApiWrapperDao;
_coreApiWrapperConfiguration = coreApiWrapperConfiguration;
}
public async Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewCheckingAccountSalesActivity(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetNewCheckingAccountSalesActivity(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get New Checking Account Sales from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<NewCheckingAccountActivity>> GetNewCheckingDigitalBankingAccountSalesActivity(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetNewCheckingDigitalBankingAccountSalesActivity(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get New Digital Banking Checking Account Sales from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<NewAtmCheckCardActivity>> GetNewAtmCheckCardSalesActivity(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetNewAtmCheckCardSalesActivity(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get New ATM and Check Card Sales from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<NewActivityManagerReferral>> GetNewActivityManagerReferralsActivity(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetNewActivityManagerReferralsActivity(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get New Activity Manager Referrals from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewMortgageSaleActivities(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetNewMortgageSaleActivities(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get New Mortgage Sales from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewVehicleSaleActivities(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetNewVehicleSaleActivities(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get New Vehicle Sales from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<NewLoanSaleActivity>> GetNewDpEligibleSaleActivities(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetNewDpEligibleSaleActivities(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get New DP Eligible Sales and Actvities from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<ActivityAccountDetails>> GetUpdatedAccountInformation(List<long> accountNumbers)
{
try
{
return await _coreApiWrapperDao.GetUpdatedAccountInformation(accountNumbers);
}
catch (Exception ex)
{
var error = $"Failed to get Updated Account Information from DNA after: {string.Join(",", accountNumbers)}" + $"Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<NewActivityManagerReferral>> GetActivityManagerActivities(ActivityQueryRequest request)
{
try
{
return await _coreApiWrapperDao.GetActivityManagerActivities(request);
}
catch (Exception ex)
{
var error = $"Failed to get Activity Manager Activities from DNA after: {request.ActivityIds} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public async Task<IReadOnlyCollection<TransactionHistory>> GetTransactionHistory(string accountNumber, DateTime startDate, DateTime endDate, List<string> transactionCodes)
{
try
{
return await _coreApiWrapperDao.GetTransactionHistory(accountNumber, startDate, endDate, transactionCodes);
}
catch (Exception ex)
{
var error = $"Failed to get Transaction History for Account Number: {accountNumber} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
public string DateTimeToUrlString(DateTime dateTime)
{
var dtstring = dateTime.ToString("yyyy-MM-ddTHH:mm:ss");
return HttpUtility.UrlEncode(dtstring);
}
public async Task<IReadOnlyCollection<EStatementDeliveryMethod>> GetEStatmentDeliveryMethods(DateTime activityDt)
{
try
{
return await _coreApiWrapperDao.GetEStatmentDeliveryMethods(activityDt);
}
catch (Exception ex)
{
var error = $"Failed to get EStatement Delivery Methods from DNA after: {activityDt} Exception Message: {ex.Message}";
Log.Error(error);
throw new ServiceException(error);
}
}
}