Example #1
0
        public LoanApplicationEntity Add(NewLoanApplication newLoanApp)
        {
            if (newLoanApp.amount > _loansConfig.Value.max_loan_amount)
            {
                _logger.LogInformation("Loan rejected due to amount > max");
                throw new ArgumentOutOfRangeException("amount");
            }

            var createApp = new Models.LoanApplicationEntity()
            {
                FullName   = newLoanApp.name,
                Amount     = newLoanApp.amount,
                LoanStatus = Models.LoanStatus.PENDING
            };

            _db.Loans.Add(createApp);
            _db.SaveChanges();

            return(createApp);
        }
Example #2
0
        public async Task <LoanApplicationEntity> AddAsync(NewLoanApplication newLoanApp)
        {
            if (newLoanApp.amount > _loansConfig.Value.max_loan_amount)
            {
                throw new ArgumentOutOfRangeException("amount");
            }

            var createApp = new Models.LoanApplicationEntity()
            {
                FullName   = newLoanApp.name,
                Amount     = newLoanApp.amount,
                LoanStatus = Models.LoanStatus.PENDING
            };

            await _db.Loans.AddAsync(createApp);

            await _db.SaveChangesAsync();

            return(createApp);
        }