public static void HandleQuoteReply(LoanQuoteReply loanQuoteReply) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Interest Rate: " + loanQuoteReply.InterestRate); Console.WriteLine("Quote Id: " + loanQuoteReply.QuoteId); Console.ResetColor(); }
private static void Timeout_Elapsed(object message) { var bankQuoteRequest = message as BankQuoteRequest; if (bankQuoteRequest == null) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("State object in bank request timeout is null."); Console.ResetColor(); } else { List <BankQuoteReply> bankQuoteReplies; LoanQuoteRequest loanRequest; if (_bankQuoteReplies.TryGetValue(bankQuoteRequest.CprNr, out bankQuoteReplies) && _loanQuoteRequests.TryGetValue(bankQuoteRequest.CprNr, out loanRequest)) { if (bankQuoteReplies.Count > 0) { var bestBankQuoteReply = bankQuoteReplies[0]; var min = 0.0; bankQuoteReplies .FindAll(reply => reply.ErrorCode != 1) .ForEach(reply => { if (!(min > reply.InterestRate)) { return; } min = reply.InterestRate; bestBankQuoteReply = reply; }); //Content Enriching var ĺoanQuoteReply = _messageTransformer.EnrichMessage(bestBankQuoteReply, loanRequest); ReplyToLoanRequest(loanRequest, ĺoanQuoteReply); } else { var negativeReply = new LoanQuoteReply { CprNr = loanRequest.CprNr, QuoteId = "ERROR_1_NoReplies" }; ReplyToLoanRequest(loanRequest, negativeReply); } } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"No Loan requests or Bank replies were found regarding Cpr.Nr: {bankQuoteRequest.CprNr}."); Console.ResetColor(); } } }
private static void ReplyToLoanRequest(LoanQuoteRequest loanRequest, LoanQuoteReply ĺoanQuoteReply) { using (var messageGateway = new MessageGateway("host=localhost;timeout=60")) { messageGateway.Send(ĺoanQuoteReply, loanRequest.ReplyQueueId); } LoanQuoteRequest removedCustomer; List <BankQuoteReply> removedBankQuoteReplies; _loanQuoteRequests.TryRemove(loanRequest.CprNr, out removedCustomer); _bankQuoteReplies.TryRemove(loanRequest.CprNr, out removedBankQuoteReplies); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"Resolved Loan request regarding Cpr.Nr {loanRequest.CprNr}."); Console.ResetColor(); }