public void GetFeesRefi()
        {
            FeeEstimateRequest estimateRequest = new FeeEstimateRequest
            {
                ClientID = 2443,  //1st mariner Bank
                OfficeID = 1,
                TransactionTypeID = 2,  //Refi
                ProductTypeID = 7,   //Refinance = Conventional = Mad EN
                City = "Boulder",
                State = "CO",
                County = "Boulder",
                LoanAmount = 200000,
                //SalesPrice = 200000,
                OriginalDebtAmount = 200000,
                UnpaidPrincipalAmount = 180000
            };

            EstimateFeesServiceFacade facade = new EstimateFeesServiceFacade();

            //FeeEstimateResult response = facade.GetFeeEstimate(estimateRequest);

            //System.Diagnostics.Debug.WriteLine(response.FeeSummaryText);

            //Assert.IsNotNull(response);
            //Assert.AreEqual(true, response.WasSuccessful);
        }
        public EstimateFeesService.EstimateFeesResponse GetFeeEstimate(FeeEstimateRequest feeEstimate)
        {
            EstimateFeesService.EstimateFeesServiceClient client = new EstimateFeesService.EstimateFeesServiceClient();
            EstimateFeesService.EstimateFeesResponse response = client.EstimateFees(
                feeEstimate.ClientID,
                feeEstimate.OfficeID,
                feeEstimate.TransactionTypeID,
                feeEstimate.ProductTypeID,
                feeEstimate.City,
                feeEstimate.County,
                feeEstimate.State,
                feeEstimate.LoanAmount,
                feeEstimate.SalesPrice,
                feeEstimate.OriginalDebtAmount,
                feeEstimate.UnpaidPrincipalAmount);

            return response;

            ////for now assume we got a response.
            ////TODO:  Handle any response and bubble back
            //if (response.ResponseCode != RESPONSE_CODE_SUCCESS)
            //{
            //    return new FeeEstimateResult(null, false, response.Message);
            //}

            //IList<Fee> fees = new List<Fee>();
            //response.HUDFees.ToList().ForEach(fee => fees.Add(new Fee(fee.Amount, fee.HUDLine, fee.HUDLineDescription)));

            //return new FeeEstimateResult(fees, true, string.Empty);
        }
        public void GetFeesPurchase()
        {
            FeeEstimateRequest estimateRequest = new FeeEstimateRequest
            {
                ClientID = 2443,  //1st mariner Bank
                OfficeID = 1,
                TransactionTypeID = 3,  //Purchase
                ProductTypeID = 4,   //Purchase - Conventional - Mad EN
                City = "Boulder",
                State = "CO",
                County = "Boulder",
                LoanAmount = 150,
                SalesPrice = 3600
            };

            EstimateFeesServiceFacade facade = new EstimateFeesServiceFacade();

            Service.EstimateFeesService.EstimateFeesResponse response = facade.GetFeeEstimate(estimateRequest);

            //System.Diagnostics.Debug.WriteLine(response.FeeSummaryText);
            //System.Diagnostics.Debug.WriteLine(response.TotalFeeAmount);

            //Assert.IsNotNull(response);
            //Assert.AreEqual(true, response.WasSuccessful);
        }
        public ActionResult PriorTransactionInfo(TransactionViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                Transaction transaction = db.Transactions.Find(viewModel.TransactionId);
                transaction.BuyerPriorLenderPolicyAmount = viewModel.Transaction.BuyerPriorLenderPolicyAmount;
                transaction.BuyerPriorLenderPolicyAvailableAsProof = viewModel.Transaction.BuyerPriorLenderPolicyAvailableAsProof;
                transaction.BuyerPriorLenderPolicyDate = viewModel.Transaction.BuyerPriorLenderPolicyDate;
                transaction.BuyerPriorOwnerPolicyAmount = viewModel.Transaction.BuyerPriorOwnerPolicyAmount;
                transaction.BuyerPriorOwnerPolicyAvailableAsProof = viewModel.Transaction.BuyerPriorOwnerPolicyAvailableAsProof;
                transaction.BuyerPriorOwnerPolicyDate = viewModel.Transaction.BuyerPriorOwnerPolicyDate;
                transaction.BuyerUnpaidBalance = viewModel.Transaction.BuyerUnpaidBalance;
                transaction.BuyerUnpaidBalanceOfPriorLoan = viewModel.Transaction.BuyerUnpaidBalanceOfPriorLoan;

                transaction.SellerPriorLenderPolicyAmount = viewModel.Transaction.SellerPriorLenderPolicyAmount;
                transaction.SellerPriorLenderPolicyAvailableAsProof = viewModel.Transaction.SellerPriorLenderPolicyAvailableAsProof;
                transaction.SellerPriorLenderPolicyDate = viewModel.Transaction.SellerPriorLenderPolicyDate;
                transaction.SellerPriorOwnerPolicyAmount = viewModel.Transaction.SellerPriorOwnerPolicyAmount;
                transaction.SellerPriorOwnerPolicyAvailableAsProof = viewModel.Transaction.SellerPriorOwnerPolicyAvailableAsProof;
                transaction.SellerPriorOwnerPolicyDate = viewModel.Transaction.SellerPriorOwnerPolicyDate;
                transaction.SellerUnpaidBalance = viewModel.Transaction.SellerUnpaidBalance;
                transaction.SellerUnpaidBalanceOfPriorLoan = viewModel.Transaction.SellerUnpaidBalanceOfPriorLoan;

                db.SaveChanges();

                //Call ResWare Fee Service to do the final calc
                EstimateFeesServiceFacade reswareFacade = new EstimateFeesServiceFacade();
                FeeEstimateRequest request = new FeeEstimateRequest();
                request.City = transaction.Property.City;
                request.ClientID = transaction.UserProfile.PartnerCompanyId;
                request.County = transaction.Property.County;
                request.LoanAmount = transaction.LoanAmount;
                request.OfficeID = transaction.UserProfile.OfficeId;
                request.OriginalDebtAmount = transaction.OriginalDebtAmount ?? 0;
                request.ProductTypeID = transaction.TransactionType.ResWareProductTypeId;
                request.SalesPrice = transaction.SalePrice ?? 0;
                request.State = transaction.Property.State;
                request.TransactionTypeID = transaction.TransactionType.ResWareTransactionTypeId;
                request.UnpaidPrincipalAmount = transaction.UnpaidPrincipalAmount ?? 0;

                ResWare.Service.EstimateFeesService.EstimateFeesResponse response = reswareFacade.GetFeeEstimate(request);

                //This needs some work and needs to be moved out.
                FeeEstimateResult result;
                if (response.HUDFees == null)
                {
                    result = new FeeEstimateResult();
                    result.WasSuccessful = false;
                    result.Message = response.Message;
                }
                else
                {
                    IList<Models.Fee> fees = new List<Models.Fee>();
                    response.HUDFees.ToList().ForEach(reswareFee =>
                    {
                        Models.Fee fee = new Models.Fee();
                        fee.Amount = reswareFee.Amount;
                        fee.HudLine = reswareFee.HUDLine;
                        fee.HudLineDescription = reswareFee.HUDLineDescription;

                        fees.Add(fee);
                    });

                    result = new FeeEstimateResult(fees, true, string.Empty);
                }

                db.FeeEstimateResults.Add(result);
                db.SaveChanges();

                transaction.FeeEstimateResult = result;
                db.SaveChanges();

                return RedirectToAction("AssessmentComplete", new { transactionId = transaction.Id });
            }

            return View(viewModel);
        }