158 lines
5.7 KiB
C#
158 lines
5.7 KiB
C#
using LCU.Library.Internal.IncentiveApiModels.Entities;
|
|
using LCU.Library.Internal.IncentiveApiModels.Enums;
|
|
using LCU.API.Internal.Operations.IncentiveApiLib.Services;
|
|
|
|
namespace LCU.API.Internal.Operations.IncentiveApi.Models.ExternalActivities;
|
|
|
|
public class NewActivityManagerReferral : IExternalActivity
|
|
{
|
|
public long ActivityId { get; set; }
|
|
public string OriginatorUserId { get; set; }
|
|
public long OriginatorPersNbr { get; set; }
|
|
public string OriginatorFirstName { get; set; }
|
|
public string OriginatorLastName { get; set; }
|
|
public string OriginatorMiddleInitial { get; set; }
|
|
public long? LandmarkCreditCardNumber { get; set; }
|
|
public long? DirectDepositAccountNumber { get; set; }
|
|
public string EmployeeEmail { get; set; }
|
|
public DateTime LastUpdatedDateTime { get; set; }
|
|
public string Campaign { get; set; }
|
|
public string Category { get; set; }
|
|
public string ReferralStation { get; set; }
|
|
public int IsInitialStation { get; set; }
|
|
public int IsFinalStation { get; set; }
|
|
public DateTime OriginationDateTime { get; set; }
|
|
public DateTime StationDateTime { get; set; }
|
|
public string OriginatingBranchName { get; set; }
|
|
public string ReferredPersonNbr { get; set; }
|
|
public string ReferredOrgNbr { get; set; }
|
|
public string ReferredPersOrgNbr { get; set; }
|
|
public string ReferredPersonName { get; set; }
|
|
public string ReferredOrgName { get; set; }
|
|
public string PreferredPhone { get; set; }
|
|
public string Comm1 { get; set; }
|
|
public string Comm2 { get; set; }
|
|
public string Comm3 { get; set; }
|
|
public string Comm4 { get; set; }
|
|
public string Comm5 { get; set; }
|
|
public string Comm6 { get; set; }
|
|
public string Comm7 { get; set; }
|
|
|
|
private static readonly TimeZoneInfo AssumedSourceTimezone = TimeZoneConverter.TZConvert.GetTimeZoneInfo("America/Chicago");
|
|
private readonly int IsInFinalStation = 1;
|
|
|
|
public Activity MapToActivity()
|
|
{
|
|
return new Activity()
|
|
{
|
|
SourceId = GetSourceId(),
|
|
Product = GetProductType(),
|
|
Accepted = GetActivityDate(),
|
|
Type = ActivityType.Referral,
|
|
SourceSystem = GetSystemType(),
|
|
SourceCreated = TimeZoneInfo.ConvertTime(OriginationDateTime, AssumedSourceTimezone, TimeZoneInfo.Utc),
|
|
Detail = new ActivityDetail()
|
|
{
|
|
MemberName = ReferredOrgName ?? ReferredPersonName,
|
|
DnaPersonNbr = OriginatorPersNbr.ToString(),
|
|
SubjectPersonNbr = ReferredPersonNbr,
|
|
SubjectOrgNbr = ReferredOrgNbr,
|
|
StationName = ReferralStation,
|
|
BranchOrgName = OriginatingBranchName,
|
|
AccountNumber = GetAccountNumber()
|
|
},
|
|
MetaData = DataParsingService.MapActivityMetaData(new List<string> { PreferredPhone, Comm1, Comm2, Comm3, Comm4, Comm5, Comm6, Comm7 }),
|
|
DepartmentId = -1,
|
|
EmployeeId = null,
|
|
State = ActivityState.Created,
|
|
EmployeeEmail = EmployeeEmail
|
|
};
|
|
}
|
|
|
|
private DateTime GetActivityDate()
|
|
{
|
|
var isLicReferral = Campaign.Equals("LIC Referral", StringComparison.InvariantCultureIgnoreCase);
|
|
if (IsFinalStation == IsInFinalStation && isLicReferral)
|
|
{
|
|
return StationDateTime = StationDateTime.Date.AddHours(12);
|
|
}
|
|
|
|
return DateTime.UtcNow.Date.AddHours(12);
|
|
}
|
|
|
|
public ActivityType GetActivityType()
|
|
{
|
|
return ActivityType.Referral;
|
|
}
|
|
|
|
public string GetSourceId()
|
|
{
|
|
return ActivityId.ToString();
|
|
}
|
|
|
|
public Product GetProductType()
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(Campaign))
|
|
{
|
|
if (Campaign.Equals("ATM Card", StringComparison.InvariantCultureIgnoreCase))
|
|
{
|
|
return Product.ATMCard;
|
|
}
|
|
|
|
if (Campaign.Equals("Check Card Referral", StringComparison.InvariantCultureIgnoreCase))
|
|
{
|
|
return Product.CheckCard;
|
|
}
|
|
|
|
if (Campaign.Equals("Checking Referral", StringComparison.InvariantCultureIgnoreCase))
|
|
{
|
|
return Product.NewChecking;
|
|
}
|
|
|
|
if (Campaign.Equals("Mortgage Referral", StringComparison.InvariantCultureIgnoreCase))
|
|
{
|
|
return Product.Mortgage;
|
|
}
|
|
|
|
if (Campaign.Equals("Direct Deposit", StringComparison.InvariantCultureIgnoreCase))
|
|
{
|
|
return Product.DirectDeposit;
|
|
}
|
|
|
|
if (Campaign.Equals("CC Balance Transfer", StringComparison.InvariantCultureIgnoreCase))
|
|
{
|
|
return Product.CreditCardBalanceTransfer;
|
|
}
|
|
|
|
if (Campaign.Equals("LIC Referral", StringComparison.InvariantCultureIgnoreCase))
|
|
{
|
|
return Product.LIC;
|
|
}
|
|
|
|
if (Campaign.Equals("First Mortgage Referral", StringComparison.InvariantCultureIgnoreCase))
|
|
{
|
|
return Product.FirstMortgageReferral;
|
|
}
|
|
|
|
if (Campaign.Equals("eStatement Referral", StringComparison.InvariantCultureIgnoreCase))
|
|
{
|
|
return Product.eStatement;
|
|
}
|
|
}
|
|
|
|
Log.Error($"Could not parse product type: {Campaign}for an incoming referral with id:{ActivityId} originating from person :{OriginatorPersNbr}");
|
|
throw new Exception("Could not parse product type for incoming referral. See logs.");
|
|
}
|
|
|
|
private string GetAccountNumber()
|
|
{
|
|
var accountNumber = (DirectDepositAccountNumber ?? LandmarkCreditCardNumber);
|
|
return accountNumber != null ? accountNumber.ToString() : null;
|
|
}
|
|
|
|
public SystemType GetSystemType()
|
|
{
|
|
return SystemType.ActivityManager;
|
|
}
|
|
}
|