private void SendBankQuoteReply(BankQuoteReply bankQuoteReply) { using (var gateway = new MessageGateway(_connectionString)) { gateway.Send(bankQuoteReply, "loan.broker.bank.reply"); } }
public LoanQuoteReply EnrichMessage(BankQuoteReply bestBankQuoteReply, LoanQuoteRequest loanRequest) { return(new LoanQuoteReply { CprNr = bestBankQuoteReply.CprNr, InterestRate = bestBankQuoteReply.InterestRate, LoanAmount = loanRequest.LoanAmount, QuoteId = bestBankQuoteReply.QuoteId }); }
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(); } }
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); }