Beispiel #1
0
        public ScoringResult Evaluate(LoanApplication loanApplication)
        {
            var brokenRules = rules
                              .Where(r => !r.IsSatisfiedBy(loanApplication))
                              .ToList();

            return(brokenRules.Any() ?
                   ScoringResult.Red(brokenRules.Select(r => r.Message).ToArray()) : ScoringResult.Green());
        }
Beispiel #2
0
        private LoanApplication(
            string number,
            LoanApplicationStatus status,
            Customer customer,
            Property property,
            Loan loan,
            ScoringResult score,
            Registration registration,
            Decision decision)
        {
            if (string.IsNullOrWhiteSpace(number))
            {
                throw new ArgumentException("Number cannot be null or empty");
            }
            if (customer == null)
            {
                throw new ArgumentException("Customer cannot be null");
            }
            if (property == null)
            {
                throw new ArgumentException("Property cannot be null");
            }
            if (loan == null)
            {
                throw new ArgumentException("Loan cannot be null");
            }
            if (registration == null)
            {
                throw new ArgumentException("Registration cannot be null");
            }

            Id           = new LoanApplicationId(Guid.NewGuid());
            Number       = number;
            Status       = status;
            Score        = score;
            Customer     = customer;
            Property     = property;
            Loan         = loan;
            Registration = registration;
            Decision     = decision;
        }