public async Task <IActionResult> CreateLoan([FromBody] CreateLoanRequestModel createLoanRequestModel) { if (!ModelState.IsValid) { return(BadRequest()); } try { var loanResult = await _loanService.CreateLoanAsync(createLoanRequestModel); if (loanResult.HasErrors()) { return(BadRequest(loanResult.ValidationErrors)); } return(CreatedAtAction(nameof(GetLoanById), new { id = loanResult.LoanDto.LoanId }, loanResult.LoanDto)); } catch (ValidationException validationException) { return(StatusCode(500, validationException.Message)); } }
public async Task <ActionResult <Guid> > CreateLoanAsync(LoanCreateModel model) { var createLoanResponseModel = await _loanService.CreateLoanAsync(model); return(Ok(createLoanResponseModel)); }