public async Task <ActionResult> View(int id) { Loan loanDetails = await _loanManagement.Get(id); return(View(loanDetails)); //TODO: View action //throw new NotImplementedException();//remove this }
public async Task <ActionResult> ViewLoan(int id) { Task <Loan> loanTask = _loanManagement.Get(id); Task <Risk> riskTask = _riskAssessment.Get(id); Task <List <Collateral> > collateralsTask = _collateralManagement.GetByLoanId(id); Loan loan; Risk risk; Collateral collateral; try { loan = await loanTask; } catch (HttpRequestException) { return(StatusCode((int)HttpStatusCode.ServiceUnavailable, new { error = "unable to connect with LoanManagementApi" })); } catch (UnexpectedResponseException) { return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = "something went wrong in LoanManagementApi" })); } try { risk = await riskTask; } catch (HttpRequestException) { return(StatusCode((int)HttpStatusCode.ServiceUnavailable, new { error = "unable to connect with RiskAssessmentApi" })); } catch (UnexpectedResponseException) { return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = "something went wrong in RiskAssessmentApi" })); } try { collateral = (await collateralsTask)[0]; } catch (HttpRequestException) { return(StatusCode((int)HttpStatusCode.ServiceUnavailable, new { error = "unable to connect with CollateralManagementApi" })); } catch (UnexpectedResponseException) { return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = "something went wrong in CollateralManagementApi" })); } if (loan == null) { return(NotFound()); } return(View("ViewLoan", new ViewLoanViewModel() { Loan = loan, Risk = risk, Collateral = collateral } )); }