public async Task <CustomerResponse> GetCustomerById(int id) { var customer = await _customerDataAgent.GetCustomerById(id); _logger.Information($"Customer retrieved. Id - {id}"); return(customer == null ? null : _customerMapper.MapToResponse(customer)); }
public async Task <int?> CreateLoan(LoanRequest loan) { var customer = await _customerDataAgent.GetCustomerById(loan.CustomerId); var customerLoans = await _loanDataAgent.GetLoansByCustomerId(loan.CustomerId); var loanObject = _loanMapper.MapToDomain(loan); if (_loanDomainService.CanCreateLoan(loanObject, customer, customerLoans)) { var createdLoanId = await _loanDataAgent.CreateLoan(loanObject); _logger.Information($"Loan created. Id - {createdLoanId}"); return(createdLoanId); } return(null); }