using System.Collections.ObjectModel; using CRIF.ACTion.Configuration; using Landmark.OLA.Models.Loan.Enums; namespace CRIF.ACTion.Services.Landmark.SourceChannel { public class LandmarkSourceChannelLookupService : ISourceChannelLookupService { private readonly CrifSettings _settings; private ReadOnlyDictionary _loanTypeToSourceChannel; public LandmarkSourceChannelLookupService(CrifSettings settings) { _settings = settings; ConfigureMapping(); } private void ConfigureMapping() { var mapping = new Dictionary { {LoanType.CC_CashBack, _settings.SourceChannels.CreditCardSourceChannelId}, {LoanType.CC_Rewards, _settings.SourceChannels.CreditCardSourceChannelId}, {LoanType.CC_Secure, _settings.SourceChannels.CreditCardSourceChannelId}, {LoanType.CC_Student, _settings.SourceChannels.CreditCardSourceChannelId}, }; _loanTypeToSourceChannel = new ReadOnlyDictionary(mapping); } public int GetSourceChannelByLoanType(LoanType loanType) { var channelId = _loanTypeToSourceChannel.TryGetValue(loanType, out int foundValue) ? foundValue : _settings.SourceChannels.DefaultSourceChannelId; return channelId; } } }