private ExtraPayments BuildExtraPayments(MortgageRequest mortgageRequest)
        {
            var result = new ExtraPayments();

            if (mortgageRequest == null)
            {
                return result;
            }

            result.ExtraPaymentInterval = mortgageRequest.ExtraPaymentInterval;
            result.ExtraPaymentAmount = mortgageRequest.ExtraPaymentAmount;

            return result;
        }
        public List<PaymentScheduleResult> PaymentScheduleResults(MortgageRequest mortgageRequest)
        {
            var result = new List<PaymentScheduleResult>();

            if (mortgageRequest == null)
            {
                return result;
            }

            if(!ValidRequest(mortgageRequest))
            {
                return result;
            }

            try
            {
                var mInfo = BuildMortgageInformation(mortgageRequest);
                var calc = new HomeMortgageCalculator();
                var pInfo = calc.GeneratePaymentSchedule(mInfo);

                foreach (var item in pInfo)
                {
                    result.Add(new PaymentScheduleResult
                                   {
                                       AdditionalPayment = item.AdditionalPayment,
                                       Balance = item.Balance,
                                       CmltvTaxReturned = item.CmltvTaxReturned,
                                       ExtraPayments = item.ExtraPayments,
                                       IntrestDue = item.IntrestDue,
                                       IntrestRate = item.IntrestRate,
                                       PaymentDate = item.PaymentDate,
                                       PaymentDue = item.PaymentDue,
                                       PaymentNumber = item.PaymentNumber,
                                       PrincipalPaid = item.PrincipalPaid,
                                       TaxReturned = item.TaxReturned
                                   });
                }
            }
            catch(Exception ex)
            {
                var error = ex;
            }

            return result;
        }
        private MortgageInformation BuildMortgageInformation(MortgageRequest mortgageRequest)
        {
            RateInformation rateInfo = BuildRateInfo(mortgageRequest);
            PaymentInformation payInfo = BuildPaymentInfo(mortgageRequest);
            ExtraPayments extraPayments = BuildExtraPayments(mortgageRequest);

            var mortgageInfo = new MortgageInformation(rateInfo, payInfo, extraPayments)
                                   {
                                       LoanAmount = mortgageRequest.LoanAmount,
                                       AnnualInterestRate = mortgageRequest.AnnualInterestRate,
                                       Term = mortgageRequest.Term,
                                       CompoundPeriod = mortgageRequest.CompoundPeriod,
                                       PaymentFrequency = mortgageRequest.PaymentFrequency,
                                       TaxBracket = mortgageRequest.TaxBracket
                                   };

            return mortgageInfo;
        }
        private PaymentInformation BuildPaymentInfo(MortgageRequest mortgageRequest)
        {
            var result = new PaymentInformation();

            if(mortgageRequest == null)
            {
                return result;
            }

            result.FirstPaymentDate = mortgageRequest.FirstPaymentDate;

            return result;
        }
        private bool ValidRequest(MortgageRequest mortgageRequest)
        {
            var valid = true;

            if(mortgageRequest == null)
            {
                return false;
            }

            if (mortgageRequest.LoanAmount > 10000000000)
            {
                valid = false;
            }

            if(mortgageRequest.Term > 60)
            {
                valid = false;
            }

            return valid;
        }
        private RateInformation BuildRateInfo(MortgageRequest mortgageRequest)
        {
            var rateInformation = new RateInformation();

            if(mortgageRequest == null)
            {
                return rateInformation;
            }

            rateInformation.EstimatedAdjustment = mortgageRequest.EstimatedAdjustment;
            rateInformation.IntrestRateCap = mortgageRequest.IntrestRateCap;
            rateInformation.IntrestRateMin = mortgageRequest.IntrestRateMin;
            rateInformation.PeriodsBetweenAdjustments = mortgageRequest.PeriodsBetweenAdjustments;
            rateInformation.RateType = mortgageRequest.RateType;
            rateInformation.YearsRateRemainsFixed = mortgageRequest.YearsRateRemainsFixed;

            return rateInformation;
        }