예제 #1
0
        public async Task <IActionResult> RegisterLoan(CreateLoanDto loanForCreate)
        {
            _logger.LogInfo("request contorller:Loan. request func: RegisterLoan ");
            var createdRetrieval = await _loanRepo.RegisterLoan(loanForCreate);

            _logger.LogInfo("responce controller:Loan. responce func RegisterLoan ");
            return(Ok(createdRetrieval));
        }
예제 #2
0
        public async Task <Loans> RegisterLoan(CreateLoanDto loanForCreate)
        {
            var currentUser   = _commonRepo.CurrentUser();
            var currentUserId = _commonRepo.CurrentUserId();

            loanForCreate.UserId           = currentUserId;
            loanForCreate.CreateDate       = DateTime.Now;
            loanForCreate.LastUpdateDate   = DateTime.Now;
            loanForCreate.LastUpdateUserId = currentUserId;
            var addLoan = _mapper.Map <Loans>(loanForCreate);

            await _context.Loans.AddAsync(addLoan);

            await _context.SaveChangesAsync();

            return(addLoan);
        }
예제 #3
0
        public IActionResult CreateLoan(CreateLoanDto createLoan)
        {
            if (_userService.CheckUserExistsById(createLoan.BorrowerId) && _userService.CheckUserExistsById(createLoan.LenderId))
            {
                var loanId = _loanService.CreateLoan(createLoan);
                if (loanId != 0)
                {
                    return(NoContent());
                }
                else
                {
                    return(StatusCode((int)Reponse.InternalServerError));
                }
            }

            return(BadRequest());
        }
예제 #4
0
        public int CreateLoan(CreateLoanDto loan)
        {
            var loanId = _loanRepository.CreateLoan(new Loan
            {
                Amount      = loan.Amount,
                BorrowerId  = loan.BorrowerId,
                LenderId    = loan.LenderId,
                LoanDate    = loan.LoanDate,
                Description = loan.Description,
                Status      = Status.Loan.ToPay
            });

            if (loanId != 0)
            {
                _userService.ChangeUserBalance(loan.BorrowerId, loan.Amount * -1);
                _userService.ChangeUserBalance(loan.LenderId, loan.Amount);
            }

            return(loanId);
        }