Exemple #1
0
        public BaseResult TestConnections(IList <HostParameter> connectorParams)
        {
            var result = new BaseResult();

            using (var tr = new Tracer("LMS.Connector.CCM.Service.Api.TestConnections"))
            {
                try
                {
                    var userName       = connectorParams.SingleOrDefault(p => p.Name == "CCM_USERNAME")?.Value;
                    var password       = connectorParams.SingleOrDefault(p => p.Name == "CCM_PASSWORD")?.Value;
                    var facility       = connectorParams.SingleOrDefault(p => p.Name == "CCM_FACILITY")?.Value;
                    var soapServiceUrl = connectorParams.SingleOrDefault(p => p.Name == "CCM_SOAP_SERVICE_URL")?.Value;
                    var restServiceUrl = connectorParams.SingleOrDefault(p => p.Name == "CCM_REST_SERVICE_URL")?.Value;
                    _userToken = connectorParams.SingleOrDefault(p => p.Name == "USERTOKEN")?.Value;

                    // Set up fake primary applicant for testing connection
                    var app = GetTestApplication();

                    var soapCredentials = new Credentials()
                    {
                        BaseUrl  = soapServiceUrl,
                        Username = userName,
                        Password = password,
                        Facility = facility
                    };
                    tr.LogObject(soapCredentials);

                    var restCredentials = new Credentials()
                    {
                        BaseUrl  = restServiceUrl,
                        Username = userName,
                        Password = password,
                        Facility = facility
                    };
                    tr.LogObject(restCredentials);

                    var soapStrategy = new SoapStrategy(app, _userToken, soapCredentials);

                    var restStrategy = new RestStrategy(app, _userToken, restCredentials);

                    var ccm = new CCMOrigination(app, _userToken, restStrategy, soapStrategy);

                    result = ccm.TestConnections(userName, password, facility, soapServiceUrl, restServiceUrl);
                }
                catch (Exception ex)
                {
                    tr.LogException(ex);
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.Service.Api.TestConnections");
                    result.AddError(ex.Message);
                    throw;
                }

                tr.Log($"LMS.Connector.CCM.Service.Api.TestConnections result => {result.Result}");
            }

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Disburses the Application to CCM.
        /// </summary>
        /// <param name="userToken"></param>
        /// <param name="app"></param>
        /// <returns></returns>
        public BaseResult DisburseApplication(string userToken, ref Application app)
        {
            var result = new BaseResult();

            _app       = app;
            _userToken = userToken;

            using (var tr = new Tracer("LMS.Connector.CCM.Service.Api.DisburseApplication"))
            {
                var restStrategy = new RestStrategy(app, userToken);

                var soapRepository = new SoapRepository(userToken);
                var soapStrategy   = new SoapStrategy(app, userToken, soapRepository);
                soapStrategy.Repository = soapRepository;

                var ccm = new CCMOrigination(app, userToken, restStrategy, soapStrategy);

                try
                {
                    result = ccm.DisburseApplication();
                }
                catch (Exception ex)
                {
                    tr.LogException(ex);
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.Service.Api.DisburseApplication");
                    result.AddError(ex.Message);
                }

                if (result.Result)
                {
                    result.AddMessage(MessageType.Success, "Loan product disbursed successfully.");
                    result.AddMessage(MessageType.Success, "Application has been disbursed.");

                    app.IsLoanDisbursed    = true;
                    app.StatusId           = (int)Akcelerant.Lending.Lookups.Constants.Values.ApplicationStatus.Disbursed;
                    app.DisbursementUserId = app.LoggedInUser.UserId;

                    tr.Log($"ApplicationId {app.ApplicationId} DisbursementUserId => {app.LoggedInUser.UserId}");
                }

                tr.Log($"ApplicationId {app.ApplicationId} IsLoanDisbursed => {app.IsLoanDisbursed}");
                tr.Log($"ApplicationId {app.ApplicationId} StatusId => {app.StatusId}");
                tr.Log($"LMS.Connector.CCM.Service.Api.DisburseApplication result => {result.Result}");
            }

            return(result);
        }