public LoanController(ILoanManagement loanManagement, IRiskAssessment riskAssessment, ICollateralManagement collateralManagement, ILogger <LoanController> logger)
 {
     _loanManagement       = loanManagement;
     _riskAssessment       = riskAssessment;
     _collateralManagement = collateralManagement;
     _logger = logger;
 }
示例#2
0
        public GetLoanResponse GetLoan(GetLoanRequest getRequest)
        {
            _log.Debug("InvokeLoanManagementService.GetLoan() starting ...");
            LoanManagementClient client = null;

            GetLoanResponse response = null;

            try
            {
                client = new LoanManagementClient();
                _log.Debug("client created successfully");
                ILoanManagement lm = (ILoanManagement)client;
                response = lm.GetLoan(getRequest);
                _log.Debug("response was received from ODS LoanManagement service");
            }
            catch (TimeoutException timeout)
            {
                _log.Error("InvokeLoanManagementService.GetLoan() Timeout Exception:" + timeout.Message);
                ProxyHelper.HandleServiceException(client);
            }
            catch (CommunicationException comm)
            {
                _log.Error("InvokeLoanManagementService.GetLoan() Communication Exception:" + comm.Message);
                ProxyHelper.HandleServiceException(client);
            }
            catch (Exception e)
            {
                _log.Error("InvokeLoanManagementService.GetLoan() Exception:" + e.Message);
            }
            finally
            {
                if (client != null && client.State != CommunicationState.Closed)
                {
                    ProxyHelper.CloseChannel(client);
                }
            }

            _log.Debug("InvokeLoanManagementService.GetLoan() ending ...");
            return(response);
        }
示例#3
0
        public GetLoanSelfReportedEntryResponse GetSelfReported(GetLoanSelfReportedEntryRequest getRequest)
        {
            _log.Info("InvokeSelfReportedService.GetSelfReported() starting ...");
            LoanManagementClient             client   = null;
            GetLoanSelfReportedEntryResponse response = null;


            try
            {
                client = new LoanManagementClient();
                ILoanManagement lm = (ILoanManagement)client;
                response = lm.GetLoanSelfReportedEntry(getRequest);
            }
            catch (TimeoutException timeout)
            {
                _log.Error("InvokeSelfReportedService.GetSelfReported() Timeout Exception:" + timeout.Message);
                ProxyHelper.HandleServiceException(client);
            }
            catch (CommunicationException comm)
            {
                _log.Error("InvokeSelfReportedService.GetSelfReported() Communication Exception:" + comm.Message);
                ProxyHelper.HandleServiceException(client);
            }
            catch (Exception e)
            {
                _log.Error("InvokeSelfReportedService.GetSelfReported() Exception:" + e.Message);
            }
            finally
            {
                if (client != null && client.State != CommunicationState.Closed)
                {
                    ProxyHelper.CloseChannel(client);
                }
            }


            _log.Info("InvokeSelfReportedService.GetSelfReported() ending ...");
            return(response);
        }
        public async Task <IActionResult> New(IFormCollection form, [FromServices] ILoanManagement loanManagement)
        {
            JsonElement loanJson        = JsonDocument.Parse(FormReader.GetLoanJson(form)).RootElement;
            JsonElement collateralsJson = JsonDocument.Parse($"[{FormReader.GetCollateralJson(form, _logger)}]").RootElement;

            _logger.LogInformation(collateralsJson.GetRawText());

            try
            {
                //return Ok(await loanManagement.SaveWithCollaterals(loanJson, collateralsJson));
                if (await loanManagement.SaveWithCollaterals(loanJson, collateralsJson))
                {
                    int newLoanId = FormReader.GetLoan(form).Id;
                    return(RedirectToAction(actionName: nameof(LoanController.ViewLoan), new { id = newLoanId }));
                }
                //return Ok("loan and collaterals saved successfully");
                else
                {
                    return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = "error occurred while saving loan and collaterals" }));
                }
            }
            catch (HttpRequestException) { return(StatusCode((int)HttpStatusCode.ServiceUnavailable, new { error = "cannot connect with LoanManagementApi" })); }
            catch (UnexpectedResponseException e) { return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = e.Message })); }
        }
 public LoanController(ILoanManagement loanManagement, IRiskAssessment riskAssessment)
 {
     _loanManagement = loanManagement;
     _riskAssessment = riskAssessment;
 }
 public RiskAssessment(ILoanManagement loanManagement, ICollateralManagement collateralManagement)
 {
     _loanManagement       = loanManagement;
     _collateralManagement = collateralManagement;
 }
 public LoanManagementController(ILoanManagement loanManagement)
 {
     _loanManagement = loanManagement;
 }