示例#1
0
        public void Execute()
        {
            //bool hasPrivilegeForManagingQueues = ( base.HttpContext.Session[ SessionHelper.PrivilegeForManagingQueues ] is bool && ( bool )base.HttpContext.Session[ SessionHelper.PrivilegeForManagingQueues ] );

            if (!InputParameters.ContainsKey("LoanId"))
            {
                throw new ArgumentException("LoanId value was expected!");
            }

            Guid loanId = Guid.Parse(InputParameters["LoanId"].ToString().TrimEnd());

            UserAccount user = null;

            if (_httpContext.Session[SessionHelper.UserData] != null)
            {
                user = ( UserAccount )_httpContext.Session[SessionHelper.UserData];
            }

            BasicLoanData loan = LoanServiceFacade.RetrieveBasicLoanData(loanId, user.UserAccountId);

            var assignLoanInfoViewModel = new AssignLoanInfoViewModel {
                LosFolders = new List <LosFolder>()
            };
            bool    importToLosInProgress   = LoanServiceFacade.ImportToFNMInProgress(loanId);
            Boolean userCanChangeLoanNumber = UserAccountServiceFacade.IsUserAuthorizedForAction(user.UserAccountId, ActionCategory.ChangeLoanNumber);

            if (loan != null)
            {
                assignLoanInfoViewModel = new AssignLoanInfoViewModel
                {
                    ConciergeId           = loan.ConciergeId,
                    EnableDigitalDocsCall = loan.EnableDigitalDocsCall,
                    LoanId                  = loan.LoanId,
                    LoanNumber              = loan.LoanNumber,
                    LoaId                   = loan.LoaId,
                    LosFolders              = LoanServiceFacade.RetrieveLosFolders(user.UserAccountId).OrderBy(l => l.FolderName).ToList(),
                    ImportToLosInProgress   = importToLosInProgress,
                    UserCanChangeLoanNumber = userCanChangeLoanNumber,
                    CompanyId               = loan.CompanyId != Guid.Empty ? loan.CompanyId.ToString() : "0",
                    ChannelId               = loan.ChannelId != null ? (Int32)loan.ChannelId : 0,
                    DivisionId              = loan.DivisionId != null ? (Int32)loan.DivisionId : 0,
                    BranchId                = loan.BranchId != Guid.Empty ? ( Guid )loan.BranchId : Guid.Empty,
                    CallCenterId            = loan.CallCenterId
                };
            }


            var losFolder = LoanServiceFacade.RetrieveLosFolder(loanId, user.UserAccountId);

            if (!String.IsNullOrEmpty(losFolder))
            {
                assignLoanInfoViewModel.LosFolder = losFolder;
            }
            else
            {
                String defaultLosFolder = LoanServiceFacade.RetrieveDefaultLosFolder(user.UserAccountId);

                if (!String.IsNullOrEmpty(defaultLosFolder))
                {
                    assignLoanInfoViewModel.LosFolder = defaultLosFolder;
                }
            }

            var isLoa = false;

            if (user.Roles != null && user.Roles.Any(r => r.RoleName == RoleName.LoanOfficerAssistant && r.IsActive))
            {
                isLoa = true;
            }

            LoadCompanies(assignLoanInfoViewModel);

            LoadChannels(assignLoanInfoViewModel);

            LoadDivisions(assignLoanInfoViewModel);

            LoadBranches(assignLoanInfoViewModel);

            LoadRelatedConciergeList(assignLoanInfoViewModel, user, loan, loanId, null, isLoa);

            LoadRelatedLoaList(assignLoanInfoViewModel, user, loan, loanId, null, isLoa);

            LoadCallCenterList(assignLoanInfoViewModel, loan);

            if (user.Roles.Any(r => r.RoleName.Equals(RoleName.Administrator)))
            {
                //base.HttpContext.Session[ SessionHelper.UserAccountIds ] = null;
                // start filling user filters by loading companies
            }
            else if (user.Roles.Any(r => r.RoleName.Equals(RoleName.BranchManager)) || user.Roles.Any(r => r.RoleName.Equals(RoleName.TeamLeader)))
            {
                // load only related users
                //LoadRelatedUsers( assignLoanInfoViewModel, base.User );
            }

            var currentStep = LoanServiceFacade.RetrieveCurrentActivityNameAndLoanStatus(loanId, user.UserAccountId);

            assignLoanInfoViewModel.EnableDownload = (currentStep != null ? currentStep.PositionIndex > 1 : false);

            var urlaDeliveryMethod = new List <DropDownItem>();

            urlaDeliveryMethod.Add(new DropDownItem()
            {
                Selected = true, Text = "FannieMae32", Value = "0"
            });
            urlaDeliveryMethod.Add(new DropDownItem()
            {
                Selected = false, Text = "Mismo23", Value = "1"
            });
            assignLoanInfoViewModel.DownloadLink       = String.Format("/Downloader.axd?documentType=urla&loanId={0}&selectedFormatValue=0", _httpContext.Server.UrlEncode(EncryptionHelper.EncryptRijndael(loanId.ToString(), EncriptionKeys.Default)));
            assignLoanInfoViewModel.UrlaDeliveryMethod = urlaDeliveryMethod;
            if (currentStep != null)
            {
                assignLoanInfoViewModel.ActivityName = currentStep.ActivityName;
            }

            var leadSourceInformation = LoanServiceFacade.RetrieveHearAboutUs(loanId);

            if (leadSourceInformation != null)
            {
                if (leadSourceInformation.AffinityGroup == Contracts.Affiliate.AffinityGroup.PartnersProfiles)
                {
                    if (leadSourceInformation.HBMId != null && leadSourceInformation.HBMId != Guid.Empty)
                    {
                        assignLoanInfoViewModel.LeadSourceInformation = leadSourceInformation.LeadSourceId + " Realtor-HBM";
                    }
                    else
                    {
                        assignLoanInfoViewModel.LeadSourceInformation = leadSourceInformation.LeadSourceId + " Realtor";
                    }
                }
                else
                {
                    assignLoanInfoViewModel.LeadSourceInformation = leadSourceInformation.LeadSourceId + " " + leadSourceInformation.Description;
                }
            }

            assignLoanInfoViewModel.TitleInformation = ConciergeWorkQueueServiceFacade.ExecuteSPGetBorrowerData("GetBorrowerData", loanId, user.UserAccountId);

            _viewName  = "_assignloaninfo";
            _viewModel = assignLoanInfoViewModel;

            /* Persist new state */
            HttpContext.Session[SessionHelper.AssignLoanInfo] = assignLoanInfoViewModel.ToXml();
        }