Exemplo n.º 1
0
        public async Task <IActionResult> Index(NewCreditCardApplicationDetails applicationDetails)
        {
            if (!ModelState.IsValid)
            {
                return(View(applicationDetails));
            }

            var creditCardApplication = new CreditCardApplication
            {
                FirstName           = applicationDetails.FirstName,
                LastName            = applicationDetails.LastName,
                FrequentFlyerNumber = applicationDetails.FrequentFlyerNumber,
                Age = applicationDetails.Age.Value,
                GrossAnnualIncome  = applicationDetails.GrossAnnualIncome.Value,
                RelationshipStatus = applicationDetails.RelationshipStatus,
                BusinessSource     = applicationDetails.BusinessSource
            };


            // There is no front-end validation required on the frequent flyer number.
            // If it is invalid the decision will be referred to a human.
            // This is so we don't miss out on potential sales due to people thinking
            // there frequent flyer number should be valid when it is not.
            var evaluator = new CreditCardApplicationEvaluator(new FrequentFlyerNumberValidator());
            CreditCardApplicationDecision decision = evaluator.Evaluate(creditCardApplication);

            creditCardApplication.Decision = decision;

            await _applicationRepository.AddAsync(creditCardApplication);

            return(View("ApplicationComplete", creditCardApplication));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Index(NewCreditCardApplicationDetails applicationDetails)
        {
            if (!ModelState.IsValid)
            {
                return(View(applicationDetails));
            }

            var creditCardApplication = new CreditCardApplication
            {
                FirstName           = applicationDetails.FirstName,
                LastName            = applicationDetails.LastName,
                FrequentFlyerNumber = applicationDetails.FrequentFlyerNumber,
                Age = applicationDetails.Age.Value,
                GrossAnnualIncome = applicationDetails.GrossAnnualIncome.Value
            };

            // Not mock-able
            var evaluator = new CreditCardApplicationEvaluator(new FrequentFlyerNumberValidator());

            creditCardApplication.Decision = evaluator.Evaluate(creditCardApplication);

            await _applicationRepository.AddAsync(creditCardApplication);

            return(View("ApplicationComplete", creditCardApplication));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Index(NewCreditCardApplicationDetails applicationDetails)
        {
            if (!ModelState.IsValid)
            {
                return(View(applicationDetails));
            }

            var creditCardApplication = new CreditCardApplication
            {
                FirstName         = applicationDetails.FirstName,
                LastName          = applicationDetails.LastName,
                Age               = applicationDetails.Age.Value,
                GrossAnnualIncome = applicationDetails.GrossAnnualIncome.Value
            };

            await _applicationRepository.AddAsync(creditCardApplication);

            return(View("ApplicationComplete", creditCardApplication));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Index(NewCreditCardApplicationDetails applicationDetails)
        {
            if (ModelState.IsValid == false)
            {
                return(View(applicationDetails));
            }

            var creditCardApplication = new CreditCardApplication
            {
                FirstName         = applicationDetails.FirstName,
                LastName          = applicationDetails.LastName,
                Age               = applicationDetails.Age.Value,
                GrossAnnualIncome = applicationDetails.GrossAnnualIncome.Value,
            };

            await _applicationRepository.AddAsync(creditCardApplication);

            var applicationId = _dataProtector.Protect(creditCardApplication.Id.ToString());

            return(RedirectToAction(nameof(ApplicationComplete), new { id = applicationId }));
        }
Exemplo n.º 5
0
 public Task AddAsync(CreditCardApplication application)
 {
     return(_applicationRepository.AddAsync(application));
 }