예제 #1
0
 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);
 }
예제 #2
0
파일: Program.cs 프로젝트: arijusg/LoanHero
        private static void PrintQuote(LoanQuote quote)
        {
            var    outputGenerator = new OutputGenerator();
            string output          = outputGenerator.Generate(quote);

            Console.WriteLine(output);
        }
예제 #3
0
파일: Program.cs 프로젝트: arijusg/LoanHero
 private static bool IsQuoteValid(int loanAmount, LoanQuote quote)
 {
     if (loanAmount != quote.RequestedAmount)
     {
         return(false);
     }
     return(true);
 }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #8
0
        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());
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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));
        }
예제 #12
0
 protected bool Equals(LoanQuote other)
 {
     return(RequestedAmount == other.RequestedAmount && InterestRate == other.InterestRate && MonthlyRepayment == other.MonthlyRepayment && TotalRepayment == other.TotalRepayment);
 }
예제 #13
0
        public IActionResult GetQuote(int id)
        {
            LoanQuote quote = _quoteQuery.Execute(id);

            return(Ok(quote));
        }
예제 #14
0
 public void SaveQuote(LoanQuote quote)
 {
     throw new System.NotImplementedException();
 }