public static GetOffersResponse GenerateOffers(GenerateOffersRequest offerJson, Guid loanApplicationGuid)
        {
            var loanApplicationOffersClient = new LoanApplicationOffersClient();
            var result = loanApplicationOffersClient.GenerateOffers(offerJson, loanApplicationGuid.ToString());

            return(result.content);
        }
        public static LoanApplicationCoreStateObject GetBorrowerToQuoting(RegisterBorrowerRequest borrower, Guid applicationGuid)
        {
            var loanApplicationOffersClient = new LoanApplicationOffersClient();
            var offerJson = new GenerateOffersRequest();

            offerJson.LoanAmount = borrower.LoanApplication.RequestedLoanAmount;
            var result      = loanApplicationOffersClient.GenerateOffers(offerJson, applicationGuid.ToString());
            var stateObject = new LoanApplicationCoreStateObject();

            stateObject.Borrower            = borrower;
            stateObject.LoanApplicationGuid = applicationGuid;
            return(stateObject);
        }
        public static LoanApplicationCoreStateObject LoanApplicationInApplyingState(RegisterBorrowerRequest borrower = null)
        {
            var result    = RegisterBorrower(borrower);
            var genOffers = new GenerateOffersRequest();

            genOffers.LoanAmount = result.Borrower.LoanApplication.RequestedLoanAmount == null ?
                                   (decimal?)(new Random().Next(5000, 35001)) : result.Borrower.LoanApplication.RequestedLoanAmount;
            var offers = GenerateOffers(genOffers, (Guid)result.LoanApplicationGuid);

            ChooseOffer((Guid)offers.LoanOfferGroup.LoanApplicationOffers[0].Guid);
            result.OfferGuid         = offers.LoanOfferGroup.LoanApplicationOffers[0].Guid;
            result.ApplicationState  = LoanApplicationState.Applying;
            result.ApplicaiontStatus = LoanApplicationStatus.AppStipsPending;
            return(result);
        }
        // return a borrower that has registered and accepted the primary offer
        public static LoanApplicationCoreStateObject GetPrimaryOffer(RegisterBorrowerRequest borrower, Guid applicationGuid, string borrowerGuid = null)
        {
            var loanApplicationOffersClient = new LoanApplicationOffersClient();
            var offerJson = new GenerateOffersRequest();

            offerJson.LoanAmount = borrower.LoanApplication.RequestedLoanAmount;
            var result = loanApplicationOffersClient.GenerateOffers(offerJson, applicationGuid.ToString());

            result = loanApplicationOffersClient.GetOffer(applicationGuid.ToString());
            var offerGuid    = result.content.LoanOfferGroup.LoanApplicationOffers[0].Guid.ToString();
            var offersClient = new OffersClient();
            var noResult     = offersClient.SelectOffer(offerGuid);
            var stateObject  = new LoanApplicationCoreStateObject();

            stateObject.Borrower = borrower;
            if (borrowerGuid != null)
            {
                stateObject.BorrowerGuid = new Guid(borrowerGuid);
            }
            stateObject.OfferGuid           = new Guid(offerGuid);
            stateObject.LoanApplicationGuid = applicationGuid;
            return(stateObject);
        }