using LCU.Library.Internal.IncentiveApiModels.Enums; using LCU.Library.Internal.IncentiveApiModels.Common; using Newtonsoft.Json; using System; namespace LCU.Library.Internal.IncentiveApiModels.Entities { public class ActivityDetail : IViewTransformable { public int Id { get; set; } public string? DnaPersonNbr { get; set; } public string? AccountNumber { get; set; } [UpdateAllowed] public string? SubAccountNumber { get; set; } [UpdateAllowed] public string? AccountStatus { get; set; } public string? AgreementNumber { get; set; } public string? SubjectPersonNbr { get; set; } public string? SubjectOrgNbr { get; set; } public string? MemberName { get; set; } [UpdateAllowed] public string? StationName { get; set; } public string? BranchOrgNbr { get; set; } public string? BranchOrgName { get; set; } public double? AccountBalance { get; set; } public double? AccountNewBalance { get; set; } public int ActivityRef { get; set; } [JsonIgnore] public Activity Activity { get; set; } [UpdateAllowed] public DateTime? DebtProtectionAddDate { get; set; } [UpdateAllowed] public DateTime? DebtProtectionRemoveDate { get; set; } public bool IsDebtProtectionEligible { get; set; } public bool IsGapInsuranceEligible { get; set; } public DateTime? GapInsuranceAddDate { get; set; } public DateTime? GapInsuranceRemoveDate { get; set; } public ActivityDetail TransformForView() { if ((Activity?.Product == Product.CreditCard || Activity?.Product == Product.CreditCardBalanceTransfer) && Activity?.Type == ActivityType.Referral) { AccountNumber = GetAccountNumber(); } return this; } private string GetAccountNumber() { if (string.IsNullOrEmpty(AccountNumber) || AccountNumber.Length <= 4) return AccountNumber; var lastDigits = AccountNumber.Substring(AccountNumber.Length - 4, 4); var maskDigits = new string('X', AccountNumber.Length - 4); return string.Concat(maskDigits, lastDigits); } } }