예제 #1
0
        public void RepaymantServieTestCase1()
        {
            /*  Loan amount = 145000
             *  Annual Interest rate = 4.5 (note this is the annual interest rate and we require a monthly repayment figure)
             *  Term years = 23
             *  Term months = 7
             *  The resulting monthly repayment = 832.33
             *  Total to be repaid = 235549.39 */

            Repayment paymentTest = new Repayment()
            {
                AnnualInterestRate = 4.5, LoanAmount = 145000, TermMonths = 7, TermYears = 23
            };

            var monthlyPaymant = paymentService.MonthlyPaymentAmount(paymentTest);
            var totalToBePaid  = paymentService.AmountPaidBack(paymentTest);

            Assert.That(monthlyPaymant, Is.EqualTo(832.33));
            Assert.That(totalToBePaid, Is.EqualTo(235549.39));
        }
예제 #2
0
        public RepaymantViewModel getRepaymentData(RepaymantViewModel model)
        {
            try
            {
                // We can use Automapper to Map View Model to Model
                var paymant = new Repayment()
                {
                    LoanAmount = model.LoanAmount, AnnualInterestRate = model.AnnualInterestRate, TermYears = model.TermYears, TermMonths = model.TermMonths
                };

                model.MonthlyRepaymant = paymentService.MonthlyPaymentAmount(paymant);
                model.TotalToBePaid    = paymentService.AmountPaidBack(paymant);

                return(model);
            }
            catch (Exception e)
            {
                throw new HttpResponseException(Request.CreateResponse(
                                                    HttpStatusCode.NotAcceptable, new ErrorResponseView(e).message));
            }
        }