Esempio n. 1
0
        public void Process(LoanApplication application)
        {
            if (application.GetApplicantSalary() < MinimumSalary)
            {
                application.Decline();
                return;
            }

            if (application.GetApplicantAge() < MinimumAge)
            {
                application.Decline();
                return;
            }

            _identityVerifier.Initialize();

            var isValidIdentity = _identityVerifier.Validate(application.GetApplicantName(),
                                                             application.GetApplicantAge(),
                                                             application.GetApplicantAddress());

            //_identityVerifier.Validate(application.GetApplicantName(),
            //                           application.GetApplicantAge(),
            //                           application.GetApplicantAddress(),
            //                           out var isValidIdentity);

            if (!isValidIdentity)
            {
                application.Decline();
                return;
            }

            //IdentityVerificationStatus status = null;

            //_identityVerifier.Validate(application.GetApplicantName(),
            //                           application.GetApplicantAge(),
            //                           application.GetApplicantAddress(),
            //                           ref status);

            //if (!status.Passed)
            //{
            //    application.Decline();
            //    return;
            //}


            _creditScorer.CalculateScore(application.GetApplicantName(),
                                         application.GetApplicantAddress());

            _creditScorer.Count++;

            if (_creditScorer.ScoreResult.ScoreValue.Score < MinimumCreditScore)
            {
                application.Decline();
                return;
            }

            application.Accept();
        }
        public void Process(LoanApplication application)
        {
            if (application is null)
            {
                throw new ArgumentNullException(nameof(application));
            }

            if (application.GetApplicantSalary() < MinimumSalary)
            {
                application.Decline();
                return;
            }

            if (application.GetApplicantAge() < MinimumAge)
            {
                application.Decline();
                return;
            }

            _identityVerifier.Initialize();

            var isValidIdentity = _identityVerifier.Validate(application.GetApplicantName(),
                                                             application.GetApplicantAge(),
                                                             application.GetApplicantAddress());

            if (!isValidIdentity)
            {
                application.Decline();
                return;
            }


            try
            {
                _creditScorer.CalculateScore(application.GetApplicantName(),
                                             application.GetApplicantAddress());
            }
            catch
            {
                application.Decline();
                return;
            }


            _creditScorer.Count++;

            if (_creditScorer.ScoreResult.ScoreValue.Score < MinimumCreditScore)
            {
                application.Decline();
                return;
            }

            application.Accept();
        }
Esempio n. 3
0
        public void Process(LoanApplication application)
        {
            if (application.GetApplicantSalary() < MinimumSalary)
            {
                application.Decline();
                return;
            }

            if (application.GetApplicantAge() < MinimumAge)
            {
                application.Decline();
                return;
            }

            _identityVerifier.Initialize();

            //var isValidIdentity = _identityVerifier.Validate(application.GetApplicantName(),
            //                                                 application.GetApplicantAge(),
            //                                                 application.GetApplicantAddress());
            _identityVerifier.Validate(application.GetApplicantName(),
                                       application.GetApplicantAge(),
                                       application.GetApplicantAddress(),
                                       out var isValidIdentity);


            if (!isValidIdentity)
            {
                application.Decline();
                return;
            }


            //_creditScorer.CalculateScore(application.GetApplicantName(),
            //                             application.GetApplicantAddress());

            //if (_creditScorer.Score < MinimumCreditScore)
            //{
            //    application.Decline();
            //    return;
            //}

            application.Accept();
        }
        public bool Process(LoanApplication application)
        {
            application.IsAccepted = false;

            if (application.Applicant.Salary < MinimumSalary)
            {
                return(application.IsAccepted);
            }

            if (application.Applicant.Age < MinimumAge)
            {
                return(application.IsAccepted);
            }

            _identityVerifier.Initialize();

            var isValidIdentity = _identityVerifier.Validate(application.Applicant.Name, application.Applicant.Age, application.Applicant.Address);

            if (!isValidIdentity)
            {
                return(application.IsAccepted);
            }

            try
            {
                _creditScorer.CalculateScore(application.Applicant.Name, application.Applicant.Address);
                /*if (_creditScorer.Score < MinimumCreditScore)*/
                if (_creditScorer.ScoreResult.ScoreValue.Score < MinimumCreditScore)
                {
                    return(application.IsAccepted);
                }
            }
            catch (Exception)
            {
                return(application.IsAccepted);
            }


            application.IsAccepted = true;
            return(application.IsAccepted);
        }