static void Main(string[] args) { string keypress; do { // 0) // Display starting menu Console.Clear(); Console.WriteLine("Adapter Pattern -- Lending Context"); Console.WriteLine(); Console.WriteLine("1) Create Loan Application"); Console.ReadKey(); // 1) // Create application var application = new LoanApplication { FirstName = RandomString.Create(RandomNumber.Create(2, 8)), LastName = RandomString.Create(RandomNumber.Create(4, 10)), Employed = RandomBool.Create(), Income = RandomNumber.Create(15000, 55000), LoanAmount = RandomNumber.Create(500, 2500) }; // 2) // Display random application for confirmation Console.Clear(); Console.WriteLine(JsonSerializer.Serialize(application)); Console.WriteLine(); Console.WriteLine("Any key to submit..."); Console.ReadKey(); // 3) // Submit application to lender var lender = new Lender(); lender.SubmitApplication(application); // 4) - Handled in Lender object // Lender verifies customer // - New API <-> Legacy API // Adapter submits individual data points // 5) - Handled in Lender object // Lender retrieves customer score // - New API <-> Legacy API // Adapter retrieves individual data points // 6) // Get the decision from the Lender var decision = lender.MakeDecision(); // 7) // Display decision Spinner(); Console.WriteLine(JsonSerializer.Serialize(decision)); Console.WriteLine(); Console.WriteLine("Menu ( M )"); Console.WriteLine("Exit ( X )"); keypress = Console.ReadKey().Key.ToString(); } while (keypress.ToLower() != "x"); }
public static bool CheckApplication(LegacyCustomer customer) { return(RandomBool.Create()); }