public void Print(LoanQuote quote) { Console.WriteLine("Requested amount: {0:c0}", quote.LoanAmount); Console.WriteLine("Rate: {0:p1}", quote.InterestRate); Console.WriteLine("Monthly repayment: {0:c2}", quote.MonthlyRepayment); Console.WriteLine("Total repayment: {0:c2}", quote.TotalRepayment); }
private static void PrintQuote(LoanQuote quote) { var outputGenerator = new OutputGenerator(); string output = outputGenerator.Generate(quote); Console.WriteLine(output); }
private static bool IsQuoteValid(int loanAmount, LoanQuote quote) { if (loanAmount != quote.RequestedAmount) { return(false); } return(true); }
public void CalculateLoan() { int amountToBorrow = 1000; var calculator = new LoanCalculator(_lenders); LoanQuote quote = calculator.Calculate(amountToBorrow, 36); var expectedQuote = new LoanQuote(1000, 0.07M, 30.88M, 1111.53M); Assert.AreEqual(expectedQuote, quote); }
public LoanQuote Calculate(int requestedAmountToBorrow, int months) { var selectedLoanLenders = SelectLendersForLoanAmount(requestedAmountToBorrow); var interestRate = GetCombinedInterestRateForTheLoan(selectedLoanLenders); var totalAmountLent = GetTotalAmountLent(selectedLoanLenders); var monthlyRepayment = GetMonthlyPayment(totalAmountLent, interestRate, months); var totalRepayment = GetTotalRepaymentValue(monthlyRepayment, totalAmountLent, interestRate, months); var quote = new LoanQuote(totalAmountLent, interestRate, monthlyRepayment, totalRepayment); return(quote); }
public LoanQuoteResponse Execute(int quoteId) { LoanQuote quote = _loanQuoteRepository.GetByID(quoteId); var response = new LoanQuoteResponse(); response.Amount = quote.Amount; response.RequestStatus = quote.Decision; response.InterestRate = quote.InterestRate; return(response); }
public LoanQuote Post(LoanQuoteRequest quoteRequest) { var quote = new LoanQuote(); double rate = 3.99; double calcRate = ((rate / 12) / 100); double factor = calcRate + (calcRate / (Math.Pow(calcRate + 1, quoteRequest.term) - 1)); quote.payment = quoteRequest.loanAmount * factor; quote.term = quoteRequest.term; quote.rate = rate; return(quote); }
public string Generate(LoanQuote quote) { var outputBuilder = new StringBuilder(); outputBuilder.Append($"Requested amount: £{quote.RequestedAmount}"); outputBuilder.AppendLine(); outputBuilder.Append($"Rate: {decimal.Round(quote.InterestRate * 100, 1)}%"); outputBuilder.AppendLine(); outputBuilder.Append($"Monthly repayment: £{decimal.Round(quote.MonthlyRepayment, 2)}"); outputBuilder.AppendLine(); outputBuilder.Append($"Total repayment: £{decimal.Round(quote.TotalRepayment, 2)}"); return(outputBuilder.ToString()); }
public LoanQuoteResponse Execute(decimal amount, int creditScore) { LoanQuote quote = new LoanQuote(amount, creditScore); quote.CalculateLoanTerms(); _loanQuoteRepository.SaveQuote(quote); LoanQuoteResponse response = new LoanQuoteResponse(); response.Amount = quote.Amount; response.RequestStatus = quote.Decision; response.InterestRate = quote.InterestRate; return(response); }
public async Task Execute_ReturnsLoanContract() { var lowQuote = new LoanQuote("Bank 1", 1); var highQuote = new LoanQuote("Bank 2", 5); var testRunner = new StatefulLinkTestRunner <CreateLoanContract, LoanApplication, LoanContract>( services => services.AddSingleton <IBankService>(new FakeBankService(new[] { lowQuote, highQuote })) ); var loanApplication = TestDataFactory.CreateLoanApplication(); var loanContract = await testRunner.ExecuteAsync(loanApplication); Assert.Equal(lowQuote.BankName, loanContract.BankName); Assert.Equal(lowQuote.InterestRate, loanContract.InterestRate); Assert.Equal(loanApplication.Ssn, loanContract.Ssn); Assert.Equal(loanApplication.Name, loanContract.Name); Assert.Equal(loanApplication.Amount, loanContract.Amount); Assert.Equal(loanApplication.LoanDuration, loanContract.LoanDuration); Assert.Equal(loanApplication.CreditScore, loanContract.CreditScore); }
protected override async Task <HttpResponseMessage> SendAsync( HttpRequestMessage request, CancellationToken cancellationToken) { var loanQuote = new LoanQuote(); loanQuote.ApprovableAmount = 100; loanQuote.Bank = "Test"; HttpResponseMessage httpResponseMessage = new HttpResponseMessage(System.Net.HttpStatusCode.OK); httpResponseMessage.Content = new StringContent( JsonConvert.SerializeObject(loanQuote), Encoding.UTF8, "application/json"); return(await Task.FromResult(httpResponseMessage)); }
protected bool Equals(LoanQuote other) { return(RequestedAmount == other.RequestedAmount && InterestRate == other.InterestRate && MonthlyRepayment == other.MonthlyRepayment && TotalRepayment == other.TotalRepayment); }
public IActionResult GetQuote(int id) { LoanQuote quote = _quoteQuery.Execute(id); return(Ok(quote)); }
public void SaveQuote(LoanQuote quote) { throw new System.NotImplementedException(); }