示例#1
0
 private void SendBankQuoteReply(BankQuoteReply bankQuoteReply)
 {
     using (var gateway = new MessageGateway(_connectionString))
     {
         gateway.Send(bankQuoteReply, "loan.broker.bank.reply");
     }
 }
示例#2
0
 public LoanQuoteReply EnrichMessage(BankQuoteReply bestBankQuoteReply, LoanQuoteRequest loanRequest)
 {
     return(new LoanQuoteReply
     {
         CprNr = bestBankQuoteReply.CprNr,
         InterestRate = bestBankQuoteReply.InterestRate,
         LoanAmount = loanRequest.LoanAmount,
         QuoteId = bestBankQuoteReply.QuoteId
     });
 }
示例#3
0
        private static void HandleBankQuoteReply(BankQuoteReply bankQuoteReply)
        {
            List <BankQuoteReply> bankQuoteReplies;

            if (_bankQuoteReplies.TryGetValue(bankQuoteReply.CprNr, out bankQuoteReplies))
            {
                var readOnlyReplies = bankQuoteReplies;
                bankQuoteReplies.Add(bankQuoteReply);
                if (_bankQuoteReplies.TryUpdate(bankQuoteReply.CprNr, bankQuoteReplies, readOnlyReplies))
                {
                    Console.WriteLine($"Received a reply from a bank regarding {bankQuoteReply.CprNr}. " +
                                      $"Current Number of replies {bankQuoteReplies.Count}");
                }
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"Unable to find a record regarding Cpr.Nr: {bankQuoteReply.CprNr}.");
                Console.ResetColor();
            }
        }
示例#4
0
        private BankQuoteReply ComputeBankReply(BankQuoteRequest requestStruct)
        {
            var replyStruct = new BankQuoteReply
            {
                CprNr = requestStruct.CprNr
            };

            if (requestStruct.LoanTerm <= _maxLoanTerm)
            {
                replyStruct.InterestRate = _primeRate + _ratePremium
                                           + (double)requestStruct.LoanTerm / 12 / 10
                                           + (double)_random.Next(10) / 10;
                replyStruct.ErrorCode = 0;
            }
            else
            {
                replyStruct.InterestRate = 0.0;
                replyStruct.ErrorCode    = 1;
            }
            replyStruct.QuoteId = $"{_bankName}-{_quoteCounter:00000}";
            _quoteCounter++;
            return(replyStruct);
        }