Exemplo n.º 1
0
        /// <summary>
        /// Returns optimal lender rate information from appropriate lenderrepostiory
        /// </summary>
        /// <returns></returns>
        public CalculatedOptimalLendRate GetOptimalLendRateInformation()
        {
            _optimalLenders = _lenderRepository.GetOptimalRateLendersForAmount(RequestedAmount).ToList();

            //check if we have sufficient to borrow
            var totalAmountLent = _optimalLenders.Sum(orl => orl.AvailableAmount);

            if (totalAmountLent < RequestedAmount)
            {
                throw new InsufficientFundsException();
            }
            var optimalLendRate = CalculateOptimalLendRate();

            return(new CalculatedOptimalLendRate(RequestedAmount, optimalLendRate));
        }