public static void PopulateComboBoxes(ManageFeesViewModel model)
        {
            var file = DocumentsServiceFacade.GetLatestFileByLoanIdAndDocumentClass(model.TitleAndEscrow.LoanId, DocumentClass.SmartGFEComplianceCertificate, model.TitleAndEscrow.UserAccountId);

            if (file != null && file.FileStoreItemId != Guid.Empty)
            {
                model.TitleAndEscrow.SmartGfeDocumentLink = HttpUtility.UrlEncode(EncryptionHelper.EncryptRijndael(file.FileStoreItemId.ToString(), EncriptionKeys.Default));
                if (!model.TitleAndEscrow.SmartGFEEnabled.HasValue)
                {
                    model.TitleAndEscrow.SmartGFEEnabled = model.TitleAndEscrow.SmartGFEEnabledOriginalValue = true;
                }
            }
            model.TitleAndEscrow.ListPaidBy = new List <string>();
            var ddlValues = LookupServiceFacade.Lookup(LookupKeywords.CostPaidBy, model.TitleAndEscrow.UserAccountId);

            foreach (var c in ddlValues)
            {
                model.TitleAndEscrow.ListPaidBy.Add(c.StringValue);
            }

            model.TitleAndEscrow.ListPaidTo = new List <string>();
            ddlValues = LookupServiceFacade.Lookup(LookupKeywords.CostPaidTo, model.TitleAndEscrow.UserAccountId);
            foreach (var c in ddlValues)
            {
                model.TitleAndEscrow.ListPaidTo.Add(c.StringValue);
            }
            model.TitleAndEscrow.ListWhen = new List <string>();
            ddlValues = LookupServiceFacade.Lookup(LookupKeywords.CostPaidWhen, model.TitleAndEscrow.UserAccountId);
            foreach (var c in ddlValues)
            {
                model.TitleAndEscrow.ListWhen.Add(c.StringValue);
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="borrower"></param>
 private static void SetupLookups(BorrowerModel borrower)
 {
     borrower.PhoneTypes      = LookupServiceFacade.Lookup(LookupKeywords.PhoneType, -1).ToList();
     borrower.MaritalStatuses = LookupServiceFacade.Lookup(LookupKeywords.MaritalStatus, -1).ToList();
     borrower.States          = LookupServiceFacade.Lookup(LookupKeywords.States, -1).ToList();
     borrower.MannerTitleHeld = LookupServiceFacade.Lookup(LookupKeywords.MannerTitleHeld, -1).ToList();
 }
Ejemplo n.º 3
0
        public InvestorConfigurationController()
        {
            _productServiceFacade = new ProductServiceFacade();
            _userAccountId        = IdentityManager.GetUserAccountId();

            _extensionDaysLookup     = LookupServiceFacade.Lookup("investorextdays", _userAccountId);
            _extensionPoliciesLookup = LookupServiceFacade.Lookup("investorextpolicies", _userAccountId);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// LookupStates
        /// </summary>
        /// <param name="loanType"></param>
        /// <param name="userAccountId"></param>
        /// <returns></returns>
        public static LookupCollection LookupStates(LoanTransactionType loanType, Int32 userAccountId)
        {
            /// TODO:   THIS IS ONLY TEMPORARY FOR CLIENT TO GET TEST DOCUMENT THIS NEEDS TO BE REFACTORED CORRECTLY
            ///         THESE VALUES SHOULD BE STORED IN DATABASE !!!!!
            ///         ADDED STATES WA, UT, OR
            String[]         purchaseStateList = { "CA", "CO", "FL", "HI", "ID", "NM", "TX", "WA", "UT", "OR" };
            LookupCollection purchaseStates    = new LookupCollection();

            purchaseStates.AddRange(LookupServiceFacade.LookupStates(userAccountId).Where(l => purchaseStateList.Contains(l.Name)).ToArray());

            return(loanType == LoanTransactionType.Purchase ? purchaseStates : LookupServiceFacade.LookupStates(userAccountId));
        }
Ejemplo n.º 5
0
        public static void RetreiveContactDetailsFromWorkQueueItemDetails(WorkQueueItemDetails workQueueItemDetails, LoanDetailsViewModel loanDetails, UserAccount user, string emptyField)
        {
            loanDetails.BorrowerFirstName        = !workQueueItemDetails.BorrowerFirstName.IsNullOrEmpty() ? StringHelper.ReduceTextSize(workQueueItemDetails.BorrowerFirstName, 10) : emptyField;
            loanDetails.BorrowerLastName         = !workQueueItemDetails.BorrowerLastName.IsNullOrEmpty() ? StringHelper.ReduceTextSize(workQueueItemDetails.BorrowerLastName, 10) : emptyField;
            loanDetails.BorrowerMiddleName       = !workQueueItemDetails.BorrowerMiddleName.IsNullOrEmpty() ? StringHelper.ReduceTextSize(workQueueItemDetails.BorrowerMiddleName, 10) : emptyField;
            loanDetails.BorrowerPreferredPhone   = !workQueueItemDetails.BorrowerPreferredPhone.IsNullOrEmpty() ? StringHelper.FormatPhoneNumber(workQueueItemDetails.BorrowerPreferredPhone) : emptyField;
            loanDetails.BorrowerAlternatePhone   = !workQueueItemDetails.BorrowerAlternatePhone.IsNullOrEmpty() ? StringHelper.FormatPhoneNumber(workQueueItemDetails.BorrowerAlternatePhone) : emptyField;
            loanDetails.CoBorrowerFirstName      = !workQueueItemDetails.CoBorrowerFirstName.IsNullOrEmpty() ? StringHelper.ReduceTextSize(workQueueItemDetails.CoBorrowerFirstName, 10) : emptyField;
            loanDetails.CoBorrowerLastName       = !workQueueItemDetails.CoBorrowerLastName.IsNullOrEmpty() ? StringHelper.ReduceTextSize(workQueueItemDetails.CoBorrowerLastName, 10) : emptyField;
            loanDetails.CoBorrowerMiddleName     = !workQueueItemDetails.CoBorrowerMiddleName.IsNullOrEmpty() ? StringHelper.ReduceTextSize(workQueueItemDetails.CoBorrowerMiddleName, 10) : emptyField;
            loanDetails.CoBorrowerPreferredPhone = !workQueueItemDetails.CoBorrowerPreferredPhone.IsNullOrEmpty() ? StringHelper.FormatPhoneNumber(workQueueItemDetails.CoBorrowerPreferredPhone) : emptyField;
            loanDetails.CoBorrowerAlternatePhone = !workQueueItemDetails.CoBorrowerAlternatePhone.IsNullOrEmpty() ? StringHelper.FormatPhoneNumber(workQueueItemDetails.CoBorrowerAlternatePhone) : emptyField;
            if (!workQueueItemDetails.BorrowerPreferredPhone.IsNullOrEmpty())
            {
                var borrowerPreferredPhoneNoType =
                    LookupServiceFacade.LookupName(Convert.ToInt32(workQueueItemDetails.BorrowerPreferredPhoneType),
                                                   LookupKeywords.PhoneType,
                                                   user.UserAccountId);
                string borrowerPreferredPhoneType = !string.IsNullOrEmpty(borrowerPreferredPhoneNoType)
                                                        ? borrowerPreferredPhoneNoType
                                                        : emptyField;
                loanDetails.BorrowerPreferredPhoneType = " (" +
                                                         StringHelper.ReduceTextSize(borrowerPreferredPhoneType, 10) +
                                                         ") ";
            }
            else
            {
                loanDetails.BorrowerPreferredPhoneType = emptyField;
            }

            if (!workQueueItemDetails.BorrowerAlternatePhone.IsNullOrEmpty())
            {
                var borrowerAlternatePhoneNoType = LookupServiceFacade.LookupName(Convert.ToInt32(workQueueItemDetails.BorrowerAlternatePhoneType), LookupKeywords.PhoneType,
                                                                                  user.UserAccountId);
                string borrowerAlternatePhoneType = !string.IsNullOrEmpty(borrowerAlternatePhoneNoType) ? borrowerAlternatePhoneNoType : emptyField;
                loanDetails.BorrowerAlternatePhoneType = " (" + StringHelper.ReduceTextSize(borrowerAlternatePhoneType, 10) + ") ";
            }
            else
            {
                loanDetails.BorrowerAlternatePhoneType = emptyField;
            }

            if (!workQueueItemDetails.CoBorrowerPreferredPhone.IsNullOrEmpty())
            {
                var coborrowerPreferredPhoneNoType =
                    LookupServiceFacade.LookupName(Convert.ToInt32(workQueueItemDetails.CoBorrowerPreferredPhoneType),
                                                   LookupKeywords.PhoneType,
                                                   user.UserAccountId);
                string coborrowerPreferredPhoneType = !string.IsNullOrEmpty(coborrowerPreferredPhoneNoType)
                                                          ? coborrowerPreferredPhoneNoType
                                                          : emptyField;
                loanDetails.CoBorrowerPreferredPhoneType = " (" +
                                                           StringHelper.ReduceTextSize(
                    coborrowerPreferredPhoneType, 10) + ") ";
            }
            else
            {
                workQueueItemDetails.CoBorrowerPreferredPhoneType = emptyField;
            }

            if (!workQueueItemDetails.CoBorrowerAlternatePhone.IsNullOrEmpty())
            {
                var coborrowerAlternatePhoneNoType = LookupServiceFacade.LookupName(Convert.ToInt32(workQueueItemDetails.CoBorrowerAlternatePhoneType), LookupKeywords.PhoneType,
                                                                                    user.UserAccountId);
                string coborrowerAlternatePhoneType = !string.IsNullOrEmpty(coborrowerAlternatePhoneNoType) ? coborrowerAlternatePhoneNoType : emptyField;
                loanDetails.CoBorrowerAlternatePhoneType = " (" + StringHelper.ReduceTextSize(coborrowerAlternatePhoneType, 10) + ") ";
            }
            else
            {
                loanDetails.CoBorrowerAlternatePhoneType = emptyField;
            }

            loanDetails.BorrowerESignNotSigned   = workQueueItemDetails.BorrowerESign == "N";
            loanDetails.CoBorrowerESignNotSigned = workQueueItemDetails.CoBorrowerESign == "N";

            // Is Borrower online user
            if (workQueueItemDetails.IsBorrowerOnlineUser.HasValue)
            {
                loanDetails.IsBorrowerOnlineUser = workQueueItemDetails.IsBorrowerOnlineUser.Value ? "Online User" : "Offline User";
            }
            else
            {
                loanDetails.IsBorrowerOnlineUser = String.Empty;
            }

            // Is CoBorrower online user
            if (workQueueItemDetails.IsCoBorrowerOnlineUser.HasValue)
            {
                loanDetails.IsCoBorrowerOnlineUser = workQueueItemDetails.IsCoBorrowerOnlineUser.Value ? "Online User" : "Offline User";
            }
            else
            {
                loanDetails.IsCoBorrowerOnlineUser = String.Empty;
            }
        }
Ejemplo n.º 6
0
        public static void RetreiveLoanDetailsFromWorkQueueItemDetails(WorkQueueItemDetails workQueueItemDetails, LoanDetailsViewModel loanDetails, UserAccount user, string emptyField)
        {
            if (workQueueItemDetails == null || loanDetails == null || user == null)
            {
                return;
            }

            loanDetails.LoanProgram     = workQueueItemDetails.LoanProgram;
            loanDetails.StreetName      = workQueueItemDetails.StreetName ?? emptyField;
            loanDetails.PropertyAddress = workQueueItemDetails.PropertyAddress ?? emptyField;
            loanDetails.EstimatedValue  = workQueueItemDetails.EstimatedValue != null
                                            ? String.Format(GlobalizationHelper.GetDefaultCulture(),
                                                            StringHelper.CurrencyFormatNoDecimals, workQueueItemDetails.EstimatedValue)
                                            : emptyField;

            loanDetails.PropertyType = workQueueItemDetails.PropertyType != 0
                                        ? LookupServiceFacade.LookupName(( int )workQueueItemDetails.PropertyType, LookupKeywords.PropertyTypeSubjectProperty, user.UserAccountId)
                                        : emptyField;
            loanDetails.OccupancyType = workQueueItemDetails.OccupancyType != 0
                                            ? LookupServiceFacade.LookupName(( int )workQueueItemDetails.OccupancyType,
                                                                             LookupKeywords.OccupancyType, user.UserAccountId)
                                            : emptyField;
            loanDetails.LoanType = workQueueItemDetails.LoanType.GetStringValue();
            loanDetails.Rate     = String.Format(GlobalizationHelper.GetDefaultCulture(), StringHelper.InterestRateFormat,
                                                 workQueueItemDetails.Rate);
            loanDetails.Apr = workQueueItemDetails.Apr != null
                                ? String.Format(GlobalizationHelper.GetDefaultCulture(), StringHelper.InterestRateFormat,
                                                workQueueItemDetails.Apr)
                                : emptyField;

            loanDetails.Points = workQueueItemDetails.Points != null?workQueueItemDetails.Points.ToString() : emptyField;

            loanDetails.LockDate = workQueueItemDetails.LockDate != null?workQueueItemDetails.LockDate.Value.ToString("MM/dd/yyyy") : emptyField;

            loanDetails.LockDays   = workQueueItemDetails.LockDays.ToString();
            loanDetails.LoanAmount =
                workQueueItemDetails.LoanAmount != null
                    ? String.Format(GlobalizationHelper.GetDefaultCulture(), StringHelper.CurrencyFormatNoDecimals, workQueueItemDetails.LoanAmount)
                    : emptyField;

            loanDetails.LoanNumber = !string.IsNullOrEmpty(workQueueItemDetails.LoanNumber) ? workQueueItemDetails.LoanNumber : emptyField;
            loanDetails.Price      = workQueueItemDetails.Price != null?workQueueItemDetails.Price.ToString() : emptyField;

            loanDetails.TotalPriceAdjustment = workQueueItemDetails.TotalPriceAdjustment != null?workQueueItemDetails.TotalPriceAdjustment.ToString() : emptyField;

            loanDetails.MonthlyPayment = workQueueItemDetails.MonthlyPayment != null
                                             ? String.Format(GlobalizationHelper.GetDefaultCulture(),
                                                             StringHelper.CurrencyFormat,
                                                             workQueueItemDetails.MonthlyPayment)
                                             : emptyField;

            loanDetails.NMLSNumber = workQueueItemDetails.ConciergeId.HasValue ? UserAccountServiceFacade.RetrieveNMLSNumber(( int )workQueueItemDetails.ConciergeId) : emptyField;

            string conciergeName = !string.IsNullOrEmpty(workQueueItemDetails.ConciergeFullName) ? workQueueItemDetails.ConciergeFullName : emptyField;

            loanDetails.ConciergeFullName = StringHelper.ReduceTextSize(conciergeName, 10);

            loanDetails.LoanPointsAmount = workQueueItemDetails.LoanPointsAmount.HasValue ?
                                           String.Format(GlobalizationHelper.GetDefaultCulture(), StringHelper.CurrencyFormat, workQueueItemDetails.LoanPointsAmount) : emptyField;

            loanDetails.LoanPointsPercentage = workQueueItemDetails.LoanPointsPercentage.HasValue && workQueueItemDetails.LoanPointsPercentage.Value > 0 ?
                                               String.Format(GlobalizationHelper.GetDefaultCulture(), StringHelper.InterestRateFormat, workQueueItemDetails.LoanPointsPercentage) : emptyField;

            if (workQueueItemDetails.LoanAmount.HasValue && workQueueItemDetails.EstimatedValue.HasValue)
            {
                loanDetails.LTV  = Calculator.Calculator.CalculateLtv(( Decimal )workQueueItemDetails.LoanAmount, workQueueItemDetails.EstimatedValue.Value);
                loanDetails.CLTV = Calculator.Calculator.CalculateCombinedLtv(( Decimal )workQueueItemDetails.LoanAmount, 0, workQueueItemDetails.EstimatedValue.Value);
            }

            loanDetails.IndexType  = workQueueItemDetails.IndexType ?? emptyField;
            loanDetails.IndexValue = workQueueItemDetails.IndexValue;
            loanDetails.Margin     = workQueueItemDetails.Margin;
            loanDetails.RateAdjustmentFirstChangeCapRate   = workQueueItemDetails.RateAdjustmentFirstChangeCapRate;
            loanDetails.RateAdjustmentLifetimeCapPercent   = workQueueItemDetails.RateAdjustmentLifetimeCapPercent;
            loanDetails.RateAdjustmentSubsequentCapPercent = workQueueItemDetails.RateAdjustmentSubsequentCapPercent;
        }
Ejemplo n.º 7
0
        private void LoadComboData(AppraisalViewModel userAppraisalViewModel, UserAccount user)
        {
            userAppraisalViewModel.States.Clear();
            userAppraisalViewModel.PropertyTypes.Clear();
            userAppraisalViewModel.OcupancyTypes.Clear();
            userAppraisalViewModel.PhoneTypes.Clear();
            userAppraisalViewModel.CrediCardTypes.Clear();
            userAppraisalViewModel.AppraisalAccessInfo.Clear();
            userAppraisalViewModel.AppraisalProducts.Clear();

            if (!userAppraisalViewModel.States.Any(s => s.Text == _genericItem.Text))
            {
                userAppraisalViewModel.States.Add(_genericItem);
            }
            if (!userAppraisalViewModel.PropertyTypes.Any(pt => pt.Text == _genericItem.Text))
            {
                userAppraisalViewModel.PropertyTypes.Add(_genericItem);
            }
            if (!userAppraisalViewModel.OcupancyTypes.Any(ot => ot.Text == _genericItem.Text))
            {
                userAppraisalViewModel.OcupancyTypes.Add(_genericItem);
            }
            //if ( !userAppraisalViewModel.PhoneTypes.Any( ph => ph.Text == _genericItem.Text ) )
            //    userAppraisalViewModel.PhoneTypes.Add( _genericItem );
            if (!userAppraisalViewModel.CrediCardTypes.Any(cc => cc.Text == _genericItem.Text))
            {
                userAppraisalViewModel.CrediCardTypes.Add(_genericItem);
            }
            if (!userAppraisalViewModel.AppraisalAccessInfo.Any(aa => aa.Text == _genericItem.Text))
            {
                userAppraisalViewModel.AppraisalAccessInfo.Add(_genericItem);
            }
            if (!userAppraisalViewModel.AppraisalProducts.Any(ap => ap.Text == _genericItem.Text))
            {
                userAppraisalViewModel.AppraisalProducts.Add(_genericItem);
            }


            LookupCollection states         = LookupServiceFacade.Lookup(LookupKeywords.States, user.UserAccountId);
            LookupCollection propertyTypes  = LookupServiceFacade.Lookup(LookupKeywords.PropertyTypeSubjectProperty, user.UserAccountId);
            LookupCollection phoneTypes     = LookupServiceFacade.Lookup(LookupKeywords.PhoneType, user.UserAccountId);
            LookupCollection crediCardTypes = LookupServiceFacade.Lookup(LookupKeywords.AppraisalCardTypes, user.UserAccountId);
            LookupCollection occupancyTypes = LookupServiceFacade.Lookup(LookupKeywords.OccupancyType, user.UserAccountId);
            LookupCollection appraisalAccessInfo;

            if (userAppraisalViewModel.Loan.LoanType == LoanTransactionType.Purchase)
            {
                appraisalAccessInfo = LookupServiceFacade.Lookup(LookupKeywords.AppraisalBusinessContactPurchase, user.UserAccountId);
            }
            else
            {
                appraisalAccessInfo = LookupServiceFacade.Lookup(LookupKeywords.AppraisalBusinessContactRefinance, user.UserAccountId);
            }

            foreach (var state in states)
            {
                userAppraisalViewModel.States.Add(new SelectListItem()
                {
                    Text  = state.Name,
                    Value = state.Value.ToString(),
                    //Selected = ( state.Value == userAppraisalViewModel.StateId )
                    Selected = (state.Value == userAppraisalViewModel.Loan.SubjectProperty.Address.StateId)
                });
            }

            foreach (var propertyType in propertyTypes)
            {
                userAppraisalViewModel.PropertyTypes.Add(new SelectListItem()
                {
                    Text  = propertyType.Name,
                    Value = propertyType.StringValue,
                    //Selected = ( propertyType.Value == userAppraisalViewModel.PropertyTypeId )
                    Selected = (propertyType.Value == ( int )userAppraisalViewModel.Loan.SubjectProperty.PropertyType)
                });
            }

            foreach (var ocupancyType in occupancyTypes)
            {
                userAppraisalViewModel.OcupancyTypes.Add(new SelectListItem()
                {
                    Text  = ocupancyType.Name,
                    Value = ocupancyType.StringValue,
                    //Selected = ( ocupancyType.Value == userAppraisalViewModel.OcupancyTypeId )
                    Selected = (ocupancyType.Value == ( int )userAppraisalViewModel.Loan.SubjectProperty.OccupancyType)
                });
            }

            foreach (var phoneType in phoneTypes)
            {
                userAppraisalViewModel.PhoneTypes.Add(new SelectListItem()
                {
                    Text  = phoneType.Name,
                    Value = phoneType.Value.ToString(),
                    //Selected = ( phoneType.Value == userAppraisalViewModel.Loan.Borrower.PhoneNumbers.PhoneTypeId )
                });
            }

            foreach (var crediCardType in crediCardTypes)
            {
                userAppraisalViewModel.CrediCardTypes.Add(new SelectListItem()
                {
                    Text  = crediCardType.Name,
                    Value = crediCardType.Value.ToString(),
                    //Selected = ( crediCardType.Value == (int)userAppraisalViewModel.OrderAppraisals[0].BillingInformation.CreditCardType )
                });
            }

            foreach (var appraisalAccess in appraisalAccessInfo)
            {
                userAppraisalViewModel.AppraisalAccessInfo.Add(new SelectListItem()
                {
                    Text     = appraisalAccess.Name,
                    Value    = appraisalAccess.Value.ToString(),
                    Selected = (appraisalAccess.Value == userAppraisalViewModel.AppraisalAccessInfoId)
                });
            }


            //Years
            userAppraisalViewModel.Years.Add(new SelectListItem()
            {
                Text     = "(Select year)",
                Value    = "-1",
                Selected = true
            });

            int now = DateTime.Now.Year;

            if (userAppraisalViewModel != null && userAppraisalViewModel.Loan != null && userAppraisalViewModel.Loan.OrderAppraisals != null &&
                userAppraisalViewModel.Loan.OrderAppraisals.Count > 0 && userAppraisalViewModel.Loan.OrderAppraisals[0].BillingInformation != null &&
                userAppraisalViewModel.Loan.OrderAppraisals[0].BillingInformation.ExpirationDate != null &&
                userAppraisalViewModel.Loan.OrderAppraisals[0].BillingInformation.ExpirationDate > DateTime.MinValue && userAppraisalViewModel.Loan.OrderAppraisals[0].BillingInformation.ExpirationDate.Year < now)
            {
                userAppraisalViewModel.Years.FirstOrDefault(x => x.Selected).Selected = false;
                userAppraisalViewModel.Years.Add(new SelectListItem()
                {
                    Text     = (userAppraisalViewModel.Loan.OrderAppraisals[0].BillingInformation.ExpirationDate.Year).ToString(),
                    Value    = (userAppraisalViewModel.Loan.OrderAppraisals[0].BillingInformation.ExpirationDate.Year).ToString(),
                    Selected = true
                });
            }

            for (int i = 0; i < 11; i++)
            {
                userAppraisalViewModel.Years.Add(new SelectListItem()
                {
                    Text     = (now + i).ToString(),
                    Value    = (now + i).ToString(),
                    Selected = false
                });
            }



            //Products
            var products = ProductServiceFacade.RetrieveProducts(new RetrieveProducts()
            {
                ProductId = null
            });

            if (products != null)
            {
                foreach (var product in products)
                {
                    userAppraisalViewModel.AppraisalProducts.Add(new SelectListItem()
                    {
                        Text  = product.Name,
                        Value = product.Value
                    });
                }
            }
        }
        public override void Execute()
        {
            base.Execute();

            try
            {
                var contactId = Guid.Empty;
                if (InputParameters.ContainsKey("ContactId"))
                {
                    Guid.TryParse(InputParameters["ContactId"].ToString().TrimEnd(), out contactId);
                }

                String loanType = String.Empty;
                if (InputParameters.ContainsKey("LoanType"))
                {
                    loanType = InputParameters["LoanType"].ToString();
                }

                int lCContactType = -1;
                if (InputParameters.ContainsKey("LCContactType"))
                {
                    Int32.TryParse(InputParameters["LCContactType"].ToString(), out lCContactType);
                }

                int lCCompanyId = 0;
                if (InputParameters.ContainsKey("LCCompanyId"))
                {
                    Int32.TryParse(InputParameters["LCCompanyId"].ToString(), out lCCompanyId);
                }

                int lCContactId = 0;
                if (InputParameters.ContainsKey("LCContactId"))
                {
                    Int32.TryParse(InputParameters["LCContactId"].ToString(), out lCContactId);
                }

                Boolean isGlobalContact = false;
                if (InputParameters.ContainsKey("IsGlobalContact"))
                {
                    isGlobalContact = bool.Parse(InputParameters["IsGlobalContact"].ToString());
                }

                var loanId = Guid.Empty;
                if (InputParameters.ContainsKey("LoanId"))
                {
                    Guid.TryParse(InputParameters["LoanId"].ToString().TrimEnd(), out loanId);
                }

                UserAccount user = null;
                if (HttpContext.Session["UserData"] != null)
                {
                    user = ( UserAccount )HttpContext.Session["UserData"];
                }
                else
                {
                    user = UserAccountServiceFacade.GetUserByName(HttpContext.User.Identity.Name);
                    HttpContext.Session["UserData"] = user;
                }

                if (user == null)
                {
                    throw new InvalidOperationException("User is null");
                }

                var             bussinesContactViewModel = new MML.Web.LoanCenter.ViewModels.BusinessContactInfoViewModel();
                BusinessContact businessContact          = null;

                /*
                 * if ( contactId != Guid.Empty )
                 *  //businessContact = BusinessContactServiceFacade.RetrieveBusinessContact( contactId );
                 *  businessContact = BusinessContactServiceFacade.RetrieveBusinessContactAppraisal( contactId );
                 */
                ContactHelper contactHelper = new ContactHelper();

                if (isGlobalContact)
                {
                    var companyModel = contactHelper.CopyGlobalCompanyToLoanCompany(lCContactType, lCCompanyId, loanId);
                    var contactModel = contactHelper.CopyGlobalContactToLoanContact(lCContactType, lCContactId, loanId);

                    LoanRealtorCompany realtor        = ( LoanRealtorCompany )companyModel;
                    LoanRealtorContact realtorContact = ( LoanRealtorContact )contactModel;
                    businessContact = contactHelper.PopulateBusinessContactFromLoanContact(realtor, realtorContact, loanId);
                }
                else if (lCCompanyId != 0 && lCContactId != 0)
                {
                    businessContact = contactHelper.GetAndPopulateBusinessContactModel(lCContactType, lCCompanyId, lCContactId, loanId);
                }

                if (businessContact == null)
                {
                    businessContact = new BusinessContact();
                    businessContact.LoanContactsContactType    = -1;
                    businessContact.LoanContactsContactSubType = 0;
                }

                if (businessContact.Seller == null)
                {
                    businessContact.Seller = new Seller();
                }

                if (businessContact.SellerAlt == null)
                {
                    businessContact.SellerAlt = new Seller();
                }

                if (businessContact.Address == null)
                {
                    businessContact.Address = new Address();
                }

                bussinesContactViewModel.BusinessContact = businessContact;
                if (businessContact != null)
                {
                    bussinesContactViewModel.BusinessContact.BusinessContactId = contactId;
                }

                bussinesContactViewModel.UserAccountId = user.UserAccountId;
                //if ( loanType == LoanTransactionType.Purchase.GetStringValue() )
                //{
                //    bussinesContactViewModel.ContactBusinessTypes = LookupServiceFacade.Lookup( LookupKeywords.BusinessContactPurchase, bussinesContactViewModel.UserAccountId );
                //}
                //else
                //{
                //    bussinesContactViewModel.ContactBusinessTypes = LookupServiceFacade.Lookup( LookupKeywords.BusinessContactRefinance, bussinesContactViewModel.UserAccountId );
                //}



                //var lookupCollection = new LookupCollection();

                //var lookupList = bussinesContactViewModel.ContactBusinessTypes.ToList().OrderBy( c => c.Name );
                //foreach ( Lookup lookup in lookupList )
                //    lookupCollection.Add( lookup );

                //bussinesContactViewModel.ContactBusinessTypes = lookupCollection;

                bussinesContactViewModel.PhoneTypes = LookupServiceFacade.Lookup(LookupKeywords.PhoneType, bussinesContactViewModel.UserAccountId);
                bussinesContactViewModel.States     = LookupServiceFacade.Lookup(LookupKeywords.States, bussinesContactViewModel.UserAccountId);
                if (bussinesContactViewModel.States != null && bussinesContactViewModel.States.SingleOrDefault(x => x.Value == -1) == null)
                {
                    bussinesContactViewModel.States.Insert(0, new Lookup(-1, String.Empty));
                }

                if (lCCompanyId == 0 && lCContactId == 0)
                {
                    bussinesContactViewModel.BusinessContact.CompanyContactsType = -1;
                }

                ViewName = "_bussinescontactinfo";
                ViewData = bussinesContactViewModel;
            }
            catch (Exception ex)
            {
                TraceHelper.Error(TraceCategory.LoanCenter, "There is some issues in method OpenBusinessContactPopupCommand.Execute(): " + ex.Message, ex);
                throw;
            }
        }