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)); }
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); }
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()); }
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); }