Example #1
0
 public async Task <bool> ApplyForLoan(Loan_ApplicationDto loan_ApplicationDto, CancellationToken cancellationToken)
 {
     return(await repository.ApplyForLoan(new Loan_Application
     {
         Submission_Date = DateTime.Now,
         Decicion_Date = null,
         Installments_Count = loan_ApplicationDto.installmentsCount,
         Amount = loan_ApplicationDto.amount,
         Repayment_Time = loan_ApplicationDto.repaymentTime,
         Status = "awaiting response",
         Bank_Account = loan_ApplicationDto.bankAccountId
     }, loan_ApplicationDto, cancellationToken));
 }
        public async Task <IActionResult> CreateLoanApplication([FromBody] Loan_ApplicationDto loan_ApplicationDto,
                                                                CancellationToken cancellationToken = default)
        {
            string l = HttpContext.GetLoginFromClaims();

            var access = await validateUserFilter.ValidateUser(l, cancellationToken);

            if (access == "admin" || access == "null")
            {
                return(Unauthorized("ERROR, Access denied"));
            }

            var success = await loanService.ApplyForLoan(loan_ApplicationDto, cancellationToken);

            if (!success)
            {
                return(UnprocessableEntity("ERROR, Loan application cannot be send"));
            }

            return(Ok());
        }