Ejemplo n.º 1
0
        public ActionResult ShowReDisclosureSection(string LoanId)
        {
            Guid loanId = Guid.Empty;
            var  model  = new ReDisclosureModel()
            {
                LoanChangeIndicators = new LoanChangeIndicators()
            };

            if (Guid.TryParse(LoanId, out loanId))
            {
                model.LoanId = loanId;

                LoanServiceFacade loanServiceFacade = new LoanServiceFacade();
                var loanIndicators = loanServiceFacade.RetrieveLoanChangeIndicators(loanId, false);
                if (loanIndicators == null)
                {
                    loanIndicators = new LoanChangeIndicatorsRetrieved();
                }

                model.LoanChangeIndicators.ChangeOfCircumstanceList       = loanIndicators.ChangeOfCircumstanceList;
                model.LoanChangeIndicators.CounterOfferApprovalItems      = loanIndicators.CounterOfferApprovalItems;
                model.LoanChangeIndicators.MdiaIndicator                  = loanIndicators.MdiaIndicator;
                model.LoanChangeIndicators.ChangeOfCircumstancesIndicator = loanIndicators.ChangeOfCircumstancesIndicator;
                model.LoanChangeIndicators.CafIndicator = loanIndicators.CafIndicator;
                model.DisplayCounterOfferApproval       = loanIndicators.CafIndicator;

                BorrowerServiceFacade borrowerServiceFacade = new BorrowerServiceFacade();
                model.IsOnlineBorrower = borrowerServiceFacade.IsOnlineBorrower(loanId);
            }

            return(PartialView("ReDisclosure/_reDisclosure", model));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// View in Borrower
        /// </summary>
        /// <param name="loanId"></param>
        /// <returns></returns>
        public String ViewInBorrower(Guid loanId, string userAccId)
        {
            int userAccountId = 0;

            int.TryParse(userAccId, out userAccountId);

            if (userAccountId == 0)
            {
                userAccountId = LoanServiceFacade.RetrieveUserAccountIdByLoanId(loanId, -1);
            }

            UserAccount concierge = ( UserAccount )HttpContext.Session["UserData"];

            LoanServiceFacade.ViewInBorrower(concierge.UserAccountId, loanId, userAccountId);

            UserAccount user = UserAccountServiceFacade.GetUserById(userAccountId);

            Guid token      = MML.Common.Impersonation.ImpersonationToken.GetToken();
            bool isInserted = ImpersonationTokenServiceFacade.InsertImpersonationToken(token, loanId, userAccountId);

            GetStartedHelper getStartedHelper = new GetStartedHelper();
            GetStarted       getStarted       = getStartedHelper.GetStarted(HttpContext, concierge, token, user.Username, false, loanId: loanId);

            return(getStarted.BorrowerUrl);
        }
Ejemplo n.º 3
0
        public ActionResult GetAllowedAusTypes(Guid loanId)
        {
            var output = new List <LoanAvailabeAus>();

            var resp = LoanServiceFacade.RetrieveAllowedAus(loanId);

            if (resp != null)
            {
                resp.Aus.ForEach(item => output.Add(new LoanAvailabeAus()
                {
                    AusType = item.ToString(),
                    Default = item == resp.Default
                }));

                #region HACK
                //output.Clear();
                //output.Add(new LoanAvailabeAus() { AusType = "DU", Default = true });
                //output.Add(new LoanAvailabeAus() { AusType = "LP", Default = false });
                #endregion
                return(Json(output, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
        private GetStarted StartNewProspectFromManageProspects(Guid loanId, int userAccountId, int contactId)
        {
            UserAccount concierge = null;

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

            if (userAccountId <= 0)
            {
                userAccountId = LoanServiceFacade.RetrieveUserAccountIdByLoanId(loanId, userAccountId);
                LoanServiceFacade.ViewInBorrower(concierge.UserAccountId, loanId, userAccountId);
            }

            UserAccount user = UserAccountServiceFacade.GetUserById(userAccountId);

            if (user == null)
            {
                return(null);
            }

            Guid token      = MML.Common.Impersonation.ImpersonationToken.GetToken();
            bool isInserted = ImpersonationTokenServiceFacade.InsertImpersonationToken(token, loanId, userAccountId);

            if (!isInserted)
            {
                return(null);
            }

            GetStartedHelper getStartedHelper = new GetStartedHelper();

            return(getStartedHelper.GetStarted(HttpContext, concierge, token, user.Username, true, contactId, loanId, openInterviewPage: 1));
        }
        public JsonResult GetLoanFromXmlForPendingApproval()
        {
            String             _xml = string.Empty;
            HttpPostedFileBase file = Request.Files[0]; //Uploaded file, we use the first one asuming that at least one file has been selected.
            //Use the following properties to get file's name, size and MIMEType
            int    fileSize = file.ContentLength;
            string fileName = file.FileName;
            string mimeType = file.ContentType;

            System.IO.Stream fileContent = file.InputStream;

            using (StreamReader reader = new StreamReader(fileContent))
            {
                _xml = reader.ReadToEnd();
            }

            Boolean toReturn = LoanServiceFacade.GetLoanFromXmlForPendingApproval(_xml, AccountHelper.GetUserAccountId());

            if (toReturn)
            {
                return(Json("OK", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("Error", JsonRequestBehavior.AllowGet));
            }
        }
        public static CancelViewModel RetrieveCancelViewModel(CancelLoanListState cancelListState, List <int> userAccountIds, GridDateFilter dateFilter, int userAccountId, Guid companyId, int channelId, int divisionId, Guid branchId, string searchTerm = null)
        {
            if (cancelListState == null)
            {
                cancelListState = new CancelLoanListState();
            }

            if (userAccountIds == null)
            {
                userAccountIds = new List <int>();
            }

            string isOnLineUser = cancelListState.BorrowerStatusFilter == null ? null :
                                  cancelListState.BorrowerStatusFilter == BorrowerStatusType.Offline.GetStringValue() ? "0" : "1";

            CancelViewData cancelViewData = LoanServiceFacade.RetrieveCancelItemsView(userAccountId, userAccountIds,
                                                                                      cancelListState.CurrentPage,
                                                                                      cancelListState.SortColumn.GetStringValue(),
                                                                                      cancelListState.SortDirection,
                                                                                      cancelListState.BoundDate,
                                                                                      searchTerm,
                                                                                      isOnLineUser,
                                                                                      companyId,
                                                                                      channelId,
                                                                                      divisionId,
                                                                                      branchId
                                                                                      ) ??
                                            new CancelViewData {
                CancelViewItems = new List <CancelViewItem>(), TotalItems = 0, TotalPages = 0
            };

            for (int i = 0; i < cancelViewData.CancelViewItems.Count; i++)
            {
                for (int j = 0; j < cancelViewData.CancelViewItems[i].CancelViewItems.Count; j++)
                {
                    DataForShortProductDescription data =
                        LoanServiceFacade.RetrieveDataForShortProductDescription(cancelViewData.CancelViewItems[i].CancelViewItems[j].LoanId);

                    cancelViewData.CancelViewItems[i].CancelViewItems[j].ProgramName = LoanHelper.FormatShortProductDescription(cancelViewData.CancelViewItems[i].CancelViewItems[j].IsHarp,
                                                                                                                                EnumHelper.GetStringValue((AmortizationType)data.AmortizationType),
                                                                                                                                data.LoanTerm,
                                                                                                                                data.FixedRateTerm,
                                                                                                                                EnumHelper.GetStringValue((MortgageType)data.MortgageType));
                }
            }

            var cancelViewModel = new CancelViewModel
            {
                BorrowerStatusList = new List <BorrowerStatusType>(Enum.GetValues(typeof(BorrowerStatusType)).Cast <BorrowerStatusType>().Skip(1)),
                CancelItems        = cancelViewData.CancelViewItems,
                PageCount          = cancelViewData.TotalPages,
                TotalItems         = cancelViewData.TotalItems
            };

            CancelGridHelper.ApplyClassCollection(cancelViewModel);
            CancelGridHelper.ProcessPagingOptions(cancelListState, cancelViewModel);


            return(cancelViewModel);
        }
Ejemplo n.º 7
0
        public ActionResult CreateCoverLetter(string LoanId, string DocumentClassId, string UserAccountId)
        {
            String message = "Failure";
            Guid   loanId;

            if (Guid.TryParse(LoanId, out loanId))
            {
                DocumentClass documentClass = DocumentClassId == "ReDisclosures" ? DocumentClass.ReDisclosuresMailingCoverLetter : DocumentClass.InitialDisclosuresMailingCoverLetter;

                if (!DocumentsServiceFacade.MailRoomCoverLetterExists(loanId, documentClass))
                {
                    var mailRoomCoverLetter = new MailRoomCoverLetter()
                    {
                        LoanId        = loanId,
                        DocumentClass = documentClass,
                        //UserAccountId = userAccountId
                    };

                    var response = LoanServiceFacade.MailingRoomCoverLetter(mailRoomCoverLetter);
                    message = response != null && response.Saved ? "Success" : "Failure";
                }
            }

            JsonResult jsonData = Json(new
            {
                Succes = message
            }, JsonRequestBehavior.AllowGet);

            return(jsonData);
        }
        public Boolean ManageProspectsSave(ManageProspectsViewModel manageProspectsViewModel)
        {
            var user = AccountHelper.GetUserAccount(HttpContext);

            Int32 status     = 0;
            Int32 concierge  = 0;
            Int32 callCenter = 0;
            Int32 loa        = 0;

            if (!String.IsNullOrEmpty(manageProspectsViewModel.SelectedCallCenter))
            {
                Int32.TryParse(manageProspectsViewModel.SelectedCallCenter, out callCenter);
            }

            if (!String.IsNullOrEmpty(manageProspectsViewModel.SelectedLoa))
            {
                Int32.TryParse(manageProspectsViewModel.SelectedLoa, out loa);
            }

            if (!String.IsNullOrEmpty(manageProspectsViewModel.SelectedStatus))
            {
                Int32.TryParse(manageProspectsViewModel.SelectedStatus, out status);
            }

            if (!String.IsNullOrEmpty(manageProspectsViewModel.SelectedConcierge))
            {
                Int32.TryParse(manageProspectsViewModel.SelectedConcierge, out concierge);
            }

            Guid companyId = Guid.Empty;

            if (!String.IsNullOrEmpty(manageProspectsViewModel.CompanyId))
            {
                Guid.TryParse(manageProspectsViewModel.CompanyId, out companyId);
            }

            var updated = ContactServiceFacade.UpdateContactProspect(
                manageProspectsViewModel.ProspectId, status, concierge, user.UserAccountId, companyId, manageProspectsViewModel.ChannelId, manageProspectsViewModel.DivisionId, manageProspectsViewModel.BranchId, callCenter, loa);

            if (manageProspectsViewModel.LoanId == Guid.Empty)
            {
                return(updated);
            }



            bool isSubmited = LoanServiceFacade.AssignOfficersToLoan(manageProspectsViewModel.LoanId, companyId, manageProspectsViewModel.ChannelId, manageProspectsViewModel.DivisionId, manageProspectsViewModel.BranchId, concierge, callCenter, loa);

            if (!isSubmited)
            {
                return(false);
            }

            ActivitiesServiceFacade.ExecuteActivityRulesConcierge(
                ActivitiesServiceFacade.RetrieveActivity(manageProspectsViewModel.LoanId, ActivityType.CompleteLoanApplication, user.UserAccountId).Id,
                ActivityStatus.Completed, ActivityMode.None, false, ActionIntent.LoanNoAndConciergeAssigned, user.Party.Id, user.UserAccountId);

            return(true);
        }
Ejemplo n.º 9
0
        public void Execute()
        {
            UserAccount user = null;

            if (_httpContext.Session[SessionHelper.UserData] != null && ((UserAccount)_httpContext.Session[SessionHelper.UserData]).Username == _httpContext.User.Identity.Name)
            {
                user = (UserAccount)_httpContext.Session[SessionHelper.UserData];
            }
            else
            {
                user = UserAccountServiceFacade.GetUserByName(_httpContext.User.Identity.Name);
            }

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

            /* parameter processing */
            Int32 contactId = 0;

            if (InputParameters.ContainsKey("ContactId"))
            {
                int.TryParse(InputParameters["ContactId"].ToString(), out contactId);
            }

            Guid loanId = Guid.Empty;

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

            var tempDetails = LoanServiceFacade.RetrieveWorkQueueItemDetails(loanId, contactId, -1);
            LoanDetailsViewModel loanDetails = new LoanDetailsViewModel();

            string emptyField = "-";

            if (tempDetails == null)
            {
                tempDetails = new WorkQueueItemDetails();
            }
            else
            {
                CommonHelper.RetreiveLoanDetailsFromWorkQueueItemDetails(tempDetails, loanDetails, user, emptyField);
            }

            if (loanDetails != null)
            {
                _viewName  = "_loanpurposeoncontact";
                _viewModel = loanDetails;
            }
            else
            {
                _viewName  = string.Empty;
                _viewModel = null;
            }
        }
        public void Execute()
        {
            try
            {
                Guid   loanServiceId = Guid.Empty;
                string eventType     = String.Empty;
                Int64  eventId       = 0;

                if (InputParameters.ContainsKey("LoanServiceId"))
                {
                    Guid.TryParse(InputParameters["LoanServiceId"].ToString(), out loanServiceId);
                }

                if (InputParameters.ContainsKey("EventType"))
                {
                    eventType = InputParameters["EventType"].ToString();
                }

                if (InputParameters.ContainsKey("EventId"))
                {
                    Int64.TryParse(InputParameters["EventId"].ToString(), out eventId);
                }

                LoanServiceContract loanServContract = null;

                if ((_httpContext != null) && (_httpContext.Session[SessionHelper.LoanServiceList] != null))
                {
                    List <LoanServiceContract> loanServiceList = null;
                    loanServiceList  = new List <LoanServiceContract>().FromXml(_httpContext.Session[SessionHelper.LoanServiceList].ToString());
                    loanServContract = loanServiceList.FirstOrDefault(x => x.LoanServiceId == loanServiceId);
                }
                else
                {
                    loanServContract = LoanServiceFacade.RetrieveLoanService(loanServiceId);
                }

                LoanServiceDocumentDownload model = new LoanServiceDocumentDownload();
                if (eventId != 0)
                {
                    LoanServiceEventsContract loanServEventContract = loanServContract.LoanServiceEventsList.FirstOrDefault(x => x.EventId == eventId && x.EventType.ToLower() == eventType.ToLower());
                    model.LoanServiceEventsList = new List <LoanServiceEventsContract>();
                    model.LoanServiceEventsList.Add(loanServEventContract);
                }
                else
                {
                    model.LoanServiceEventsList = loanServContract.LoanServiceEventsList;
                }

                _viewName  = "Log/_loanServiceDocumentDownload";
                _viewModel = model;
            }
            catch (Exception ex)
            {
                TraceHelper.Error(TraceCategory.LoanCenter, "There is some issues in method OpenLoanServiceDownloadPopupCommand.Execute(): " + ex.Message, ex);
                throw;
            }
        }
        public static AlertsViewModel RetrieveAlertViewModel(AlertsListState alertsListState, List <int> userAccountIds, GridDateFilter dateFilter, int userAccountId, Guid companyid, int channelId, int divisionId, Guid branchId, string searchTerm = null)
        {
            if (alertsListState == null)
            {
                alertsListState = new AlertsListState();
            }

            if (userAccountIds == null)
            {
                userAccountIds = new List <int>();
            }

            var alertsViewData = AlertMessageServiceFacade.RetrieveAlertItemsView(userAccountId, userAccountIds,
                                                                                  alertsListState.CurrentPage,
                                                                                  alertsListState.SortColumn.GetStringValue(),
                                                                                  alertsListState.SortDirection,
                                                                                  alertsListState.BoundDate,
                                                                                  searchTerm,
                                                                                  alertsListState.LoanPurposeFilter,
                                                                                  alertsListState.ActivityTypeFilter,
                                                                                  companyid, channelId, divisionId, branchId
                                                                                  ) ??
                                 new AlertViewData {
                AlertItems = new List <AlertViewItem>(), TotalItems = 0, TotalPages = 0, NumberOfAlerts = 0
            };


            foreach (AlertViewItem alertViewItems in alertsViewData.AlertItems)
            {
                foreach (AlertView alertViewItem in alertViewItems.AlertViewItems)
                {
                    DataForShortProductDescription data =
                        LoanServiceFacade.RetrieveDataForShortProductDescription(alertViewItem.LoanId);

                    alertViewItem.ProgramName = LoanHelper.FormatShortProductDescription(alertViewItem.IsHarp,
                                                                                         ((AmortizationType)data.AmortizationType).GetStringValue(),
                                                                                         data.LoanTerm,
                                                                                         data.FixedRateTerm,
                                                                                         ((MortgageType)data.MortgageType).GetStringValue());
                }
            }
            var alertsViewModel = new AlertsViewModel
            {
                ActivityTypeList = CommonHelper.RetrieveActivityListForQueueFilter(),
                LoanPurposeList  = new List <LoanTransactionType>(Enum.GetValues(typeof(LoanTransactionType)).Cast <LoanTransactionType>().Skip(1)),
                AlertItems       = alertsViewData.AlertItems,
                PageCount        = alertsViewData.TotalPages,
                TotalItems       = alertsViewData.TotalItems,
                NumberOfAlerts   = alertsViewData.NumberOfAlerts
            };

            AlertsGridHelper.ProcessPagingOptions(alertsListState, alertsViewModel);
            AlertsGridHelper.ApplyClassCollection(alertsViewModel);

            return(alertsViewModel);
        }
        //
        // GET: /ManageFees/
        #region ClosingCosts
        public ActionResult ShowClosingCostsHistory(String loanId)
        {
            Guid loanIdParsed = Guid.Parse(loanId);
            List <ClosingDateHistory> closingDateHistory = new List <ClosingDateHistory>();

            closingDateHistory = LoanServiceFacade.RetrieveClosingDateHistory(loanIdParsed, AccountHelper.GetUserAccountId());


            return(PartialView("Commands/ManageFees/_closingCostsHistory", closingDateHistory));
        }
Ejemplo n.º 13
0
        public static MailRoomViewModel RetrieveMailRoomViewModel(MailRoomListState mailRoomListState, List <int> userAccountIds, int userAccountId, Guid companyId, int channelId, int divisionId, Guid branchId, string searchTerm = null)
        {
            if (mailRoomListState == null)
            {
                mailRoomListState = new MailRoomListState();
            }

            if (userAccountIds == null)
            {
                userAccountIds = new List <int>();
            }

            MailRoomViewData mailRoomViewData = LoanServiceFacade.RetrieveMailRoomItemsView(userAccountIds,
                                                                                            mailRoomListState.CurrentPage,
                                                                                            mailRoomListState.SortColumn.GetStringValue(),
                                                                                            mailRoomListState.SortDirection,
                                                                                            userAccountId,
                                                                                            searchTerm,
                                                                                            mailRoomListState.DocumentTypeFilter,
                                                                                            mailRoomListState.BoundDate,
                                                                                            companyId,
                                                                                            channelId,
                                                                                            divisionId,
                                                                                            branchId
                                                                                            );

            if (mailRoomViewData == null)
            {
                mailRoomViewData = new MailRoomViewData {
                    MailRoomItems = new List <MailRoomView>(), TotalItems = 0, TotalPages = 0
                };
            }
            // Set paging numbers
            else if (userAccountIds.Any())
            {
                mailRoomViewData.TotalItems = mailRoomViewData.TotalItems;
                mailRoomViewData.TotalPages = mailRoomViewData.TotalItems / 10;
                if ((mailRoomViewData.TotalItems % 10) != 0)
                {
                    mailRoomViewData.TotalPages++;
                }
            }

            MailRoomViewModel mailRoomViewModel = new MailRoomViewModel
            {
                MailRoomItems = mailRoomViewData.MailRoomItems,
                PageCount     = mailRoomViewData.TotalPages,
                TotalItems    = mailRoomViewData.TotalItems
            };

            MailRoomGridHelper.ProcessPagingOptions(mailRoomListState, mailRoomViewModel);
            //MailRoomGridHelper.ApplyClassCollection( mailRoomViewModel );

            return(mailRoomViewModel);
        }
Ejemplo n.º 14
0
        private void LoadOrderAppraisalDataFull(AppraisalViewModel userAppraisalViewModel, UserAccount user)
        {
            // Create request object
            RetrieveOrderAppraisalDataFull request = new RetrieveOrderAppraisalDataFull()
            {
                LoanId = _loanId
            };

            // Call iMP platform
            var results = new Proxy().Send("RetrieveOrderAppraisalWorkflow", new Dictionary <string, object> {
                { "Request", request }
            });

            // Get results
            object responseMessageSuccess;

            results.TryGetValue("Response", out responseMessageSuccess);
            Loan loanWithAppraisals = responseMessageSuccess as Loan;

            if (loanWithAppraisals != null)
            {
                userAppraisalViewModel.Loan = loanWithAppraisals;

                if (userAppraisalViewModel.Loan.OrderAppraisals != null)
                {
                    for (int i = 0; i < loanWithAppraisals.OrderAppraisals.Count; i++)
                    {
                        if (loanWithAppraisals.OrderAppraisals[i].OrderAppraisalProductsFees == null || loanWithAppraisals.OrderAppraisals[i].OrderAppraisalProductsFees.Count == 0)
                        {
                            GetProductsAndFees(userAppraisalViewModel, i);
                        }
                        else if (loanWithAppraisals.OrderAppraisals[i].OrderAppraisalProductsFees != null && loanWithAppraisals.OrderAppraisals[i].OrderAppraisalProductsFees.Count > 0)
                        {
                            //Split Appraisal Condition string
                            loanWithAppraisals.OrderAppraisals[i].AppraisalCondition = loanWithAppraisals.OrderAppraisals[i].AppraisalCondition.SplitCamelCase();
                        }
                        // Need to refactor this later we don't want to add empty fees in list
                        var additionalItems = 7 - (loanWithAppraisals.OrderAppraisals[i].OrderAppraisalProductsFees != null ? loanWithAppraisals.OrderAppraisals[i].OrderAppraisalProductsFees.Count : 0);

                        for (var j = 0; j < additionalItems; j++)
                        {
                            loanWithAppraisals.OrderAppraisals[i].OrderAppraisalProductsFees.Add(new OrderAppraisalProductFee());
                        }
                    }


                    userAppraisalViewModel.ActualInvestor = LoanServiceFacade.RetrieveInvestorName(userAppraisalViewModel.Loan.ProgramName).InvestorName;
                }
            }
            else
            {
                userAppraisalViewModel.Loan.OrderAppraisals.Add(new OrderAppraisalFull());
            }
        }
        public LoanDetailsModel OpenConciergeCommandEmbedded(string workQueueType, string action, Guid loanId, string prospectId)
        {
            var user = ( UserAccount )HttpContext.Session[SessionHelper.UserData];

            if (action == "DefaultCommand")
            {
                if (workQueueType == "Prospects")
                {
                    action = loanId == Guid.Empty ? "Manage Prospects" : "Manage Loan Application";
                }
                else
                {
                    action = "Manage Loan Application";
                }
            }

            String additionalInformation = "";

            if (action == "Manage Disclosures")
            {
                additionalInformation = GeneralSettingsServiceFacade.RetrieveeSigningVendorIntegrationEnabled() &&
                                        LoanServiceFacade.RetrieveeSigningEnabledForLoan(loanId)
                                            ? "eSigning Room"
                                            : "";
            }

            var titleInformation = ConciergeWorkQueueServiceFacade.ExecuteSPGetBorrowerData("GetBorrowerData", loanId, user.UserAccountId);

            LeadSource leadSource  = LoanServiceFacade.RetrieveHearAboutUs(loanId);
            string     hearAboutUs = string.Empty;

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

            return(new LoanDetailsModel {
                Title = action, TitleInformation = titleInformation, AdditionalInformation = additionalInformation, HearAboutUs = hearAboutUs
            });
        }
        public Boolean SaveAssignInfo(AssignLoanInfoViewModel assignLoanInfoViewModel)
        {
            UserAccount user = null;

            if (Session[SessionHelper.UserData] != null)
            {
                user = ( UserAccount )Session[SessionHelper.UserData];
            }
            try
            {
                var loaId       = assignLoanInfoViewModel.LoaId.HasValue ? assignLoanInfoViewModel.LoaId.Value : -1;
                var conciergeId = assignLoanInfoViewModel.ConciergeId.HasValue ? assignLoanInfoViewModel.ConciergeId.Value : -1;

                var callCenterId = assignLoanInfoViewModel.CallCenterId.HasValue ? assignLoanInfoViewModel.CallCenterId.Value : -1;

                Guid companyId = Guid.Empty;

                if (!String.IsNullOrEmpty(assignLoanInfoViewModel.CompanyId))
                {
                    Guid.TryParse(assignLoanInfoViewModel.CompanyId, out companyId);
                }

                int  loanNumber;
                bool isLoanNumberAssigned = int.TryParse(assignLoanInfoViewModel.LoanNumber, out loanNumber) && loanNumber > 0;

                if (user != null && !isLoanNumberAssigned)
                {
                    string loanNum = LoanServiceFacade.RetrieveLoanNumber(assignLoanInfoViewModel.LoanId, user.UserAccountId);
                    isLoanNumberAssigned = int.TryParse(loanNum, out loanNumber) && loanNumber > 0;
                }

                bool isSubmited = LoanServiceFacade.AssignConciergeLoanNumberAndLOA(assignLoanInfoViewModel.LoanId, conciergeId, assignLoanInfoViewModel.LoanNumber, assignLoanInfoViewModel.ConciergeNMLS, companyId, assignLoanInfoViewModel.ChannelId, assignLoanInfoViewModel.DivisionId, assignLoanInfoViewModel.BranchId, assignLoanInfoViewModel.EnableDigitalDocsCall, user.UserAccountId, loaId, callCenterId);

                if (isSubmited)
                {
                    int losFolderId = int.Parse(assignLoanInfoViewModel.LosFolder);
                    isSubmited = LoanServiceFacade.UpdateLosFolderId(assignLoanInfoViewModel.LoanId, losFolderId, user.UserAccountId);
                }

                if (isSubmited)
                {
                    isSubmited = ActivitiesServiceFacade.ExecuteActivityRulesConcierge(ActivitiesServiceFacade.RetrieveActivity(assignLoanInfoViewModel.LoanId, ActivityType.CompleteLoanApplication, user.UserAccountId).Id,
                                                                                       ActivityStatus.Completed, ActivityMode.None, false, ActionIntent.LoanNoAndConciergeAssigned, user.Party.Id, user.UserAccountId, loanNumberAlreadyAssigned: isLoanNumberAssigned);
                }

                return(isSubmited);
            }
            catch (Exception exception)
            {
                TraceHelper.Error(TraceCategory.Global, "ExportToLOS::LosFolderUpdated", exception, assignLoanInfoViewModel.LoanId, user != null ? user.UserAccountId : -1);
                return(false);
            }
        }
Ejemplo n.º 17
0
        public void SubmitForm(ReDisclosureModel model)
        {
            string counterOfferApproval = null;

            var userAccountId = IdentityManager.GetUserAccountId();

            LoanServiceFacade loanServiceFacade = new LoanServiceFacade();

            model.LoanChangeIndicators.ChangeOfCircumstancesIndicator = model.LoanChangeIndicators.ChangeOfCircumstanceList != null && model.LoanChangeIndicators.ChangeOfCircumstanceList.Exists(c => c.Checked);
            loanServiceFacade.SaveLoanChangeIndicators(userAccountId, model.LoanId, model.LoanChangeIndicators, counterOfferApproval, true);
            // Delete any previous LoanChangeIndicators which may had been created
            loanServiceFacade.DeleteDiscardedLoanChangeIndicators(model.LoanId);
        }
Ejemplo n.º 18
0
        public void DeleteDiscardedLoanChangeIndicators(string loanId)
        {
            Guid lid = Guid.Empty;

            if (!Guid.TryParse(loanId, out lid))
            {
                return;
            }

            LoanServiceFacade loanServiceFacade = new LoanServiceFacade();

            loanServiceFacade.DeleteDiscardedLoanChangeIndicators(lid);
        }
        /// <summary>
        /// This method copies or duplicate a loan based upon its loandID
        /// </summary>
        /// <param name="loanId"></param>
        /// <returns></returns>
        public JsonResult CopyLoan(Guid loanId)
        {
            Boolean toReturn = LoanServiceFacade.CopyLoan(loanId, AccountHelper.GetUserAccountId());

            if (toReturn)
            {
                return(Json("OK", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("Error", JsonRequestBehavior.AllowGet));
            }
        }
        public static NewLoanApplicationViewModel RetrieveNewApplicationViewModel(NewLoanApplicationListState newLoanApplicationListState, List <int> userAccountIds, int userAccountId, Guid companyId, int channelId, int divisionId, Guid branchId, string searchTerm = null)
        {
            if (newLoanApplicationListState == null)
            {
                newLoanApplicationListState = new NewLoanApplicationListState();
            }

            if (userAccountIds == null)
            {
                userAccountIds = new List <int>();
            }

            string isOnLineUser = String.IsNullOrEmpty(newLoanApplicationListState.BorrowerStatusFilter) ? String.Empty :
                                  newLoanApplicationListState.BorrowerStatusFilter == BorrowerStatusType.Offline.GetStringValue() ? "0" : "1";

            NewLoanApplicationViewData newLoanApplicationViewData = LoanServiceFacade.RetrieveNewLoanApplicationItemsView(userAccountIds,
                                                                                                                          newLoanApplicationListState.CurrentPage,
                                                                                                                          newLoanApplicationListState.SortColumn.GetStringValue(),
                                                                                                                          newLoanApplicationListState.SortDirection,
                                                                                                                          newLoanApplicationListState.BoundDate,
                                                                                                                          userAccountId,
                                                                                                                          searchTerm,
                                                                                                                          companyId,
                                                                                                                          channelId,
                                                                                                                          divisionId,
                                                                                                                          newLoanApplicationListState.LoanPurposeFilter,
                                                                                                                          isOnLineUser,
                                                                                                                          branchId
                                                                                                                          );

            if (newLoanApplicationViewData == null)
            {
                newLoanApplicationViewData = new NewLoanApplicationViewData {
                    NewLoanApplicationItems = new List <NewLoanApplicationViewItem>(), TotalItems = 0, TotalPages = 0
                };
            }

            NewLoanApplicationViewModel newLoanApplicationViewModel = new NewLoanApplicationViewModel
            {
                NewLoanApplicationViewItems = newLoanApplicationViewData.NewLoanApplicationItems,
                PageCount          = newLoanApplicationViewData.TotalPages,
                TotalItems         = newLoanApplicationViewData.TotalItems,
                LoanPurposeList    = new List <LoanTransactionType>(Enum.GetValues(typeof(LoanTransactionType)).Cast <LoanTransactionType>().Skip(1)),
                BorrowerStatusList = new List <BorrowerStatusType>(Enum.GetValues(typeof(BorrowerStatusType)).Cast <BorrowerStatusType>().Skip(1)),
            };

            NewLoanApplicationGridHelper.ProcessPagingOptions(newLoanApplicationListState, newLoanApplicationViewModel);
            NewLoanApplicationGridHelper.ApplyClassCollection(newLoanApplicationViewModel);

            return(newLoanApplicationViewModel);
        }
Ejemplo n.º 21
0
        public ActionResult UpdateDefaultAus(Guid loanid, string defaultAus)
        {
            if (string.IsNullOrWhiteSpace(defaultAus))
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }

            var loanExtRef = new LoanExternalReference()
            {
                LoanId = loanid, Name = DEFAULT_AUS, Value = defaultAus
            };
            var result = LoanServiceFacade.UpdateLoanExternalReference(loanExtRef);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 22
0
        public static OrderRequestedViewModel RetrieveOrderRequestedViewModel(OrderRequestedListState orderRequestedListState, List <int> userAccountIds, int userAccountId, Guid companyId, int channelId, int divisionId, Guid branchId, string searchTerm = null)
        {
            if (orderRequestedListState == null)
            {
                orderRequestedListState = new OrderRequestedListState();
            }

            if (userAccountIds == null)
            {
                userAccountIds = new List <Int32>();
            }

            OrderRequestedViewData orderRequestedViewData = LoanServiceFacade.RetrieveOrderRequestedLoans(userAccountIds,
                                                                                                          orderRequestedListState.CurrentPage,
                                                                                                          orderRequestedListState.SortColumn.GetStringValue(),
                                                                                                          orderRequestedListState.SortDirection,
                                                                                                          orderRequestedListState.BoundDate,
                                                                                                          orderRequestedListState.OrderType,
                                                                                                          orderRequestedListState.NonConforming,
                                                                                                          orderRequestedListState.Rush,
                                                                                                          orderRequestedListState.LoanPurposeFilter,
                                                                                                          orderRequestedListState.NonConformingFilter,
                                                                                                          orderRequestedListState.RushFilter,
                                                                                                          userAccountId,
                                                                                                          searchTerm,
                                                                                                          companyId, channelId, divisionId, branchId);

            if (orderRequestedViewData == null)
            {
                orderRequestedViewData = new OrderRequestedViewData {
                    RequestedOrders = new List <RequestedOrdersView>(), TotalItems = 0, TotalPages = 0
                };
            }

            OrderRequestedViewModel orderRequestedViewModel = new OrderRequestedViewModel
            {
                RequestedOrders = orderRequestedViewData.RequestedOrders,
                PageCount       = orderRequestedViewData.TotalPages,
                LoanPurposeList = new List <LoanTransactionType>(Enum.GetValues(typeof(LoanTransactionType)).Cast <LoanTransactionType>().Skip(1)),
                TotalItems      = orderRequestedViewData.TotalItems
            };

            OrderRequestedGridHelper.ProcessPagingOptions(orderRequestedListState, orderRequestedViewModel);
            OrderRequestedGridHelper.ApplyClassCollection(orderRequestedViewModel);

            return(orderRequestedViewModel);
        }
Ejemplo n.º 23
0
        public static PreApprovalViewModel RetrievePreApprovalViewModel(PreApprovalListState preApprovalListState, List <int> userAccountIds, int userAccountId, string searchTerm, Guid companyId, int channelId, int divisionId, Guid branchId)
        {
            if (preApprovalListState == null)
            {
                preApprovalListState = new PreApprovalListState();
            }

            if (userAccountIds == null)
            {
                userAccountIds = new List <int>();
            }

            PreApprovalViewData preApprovalViewData = LoanServiceFacade.RetrievePreApprovalItemsView(userAccountIds,
                                                                                                     preApprovalListState.CurrentPage,
                                                                                                     preApprovalListState.SortColumn.GetStringValue(),
                                                                                                     preApprovalListState.SortDirection,
                                                                                                     preApprovalListState.BoundDate,
                                                                                                     userAccountId,
                                                                                                     searchTerm,
                                                                                                     companyId,
                                                                                                     channelId,
                                                                                                     divisionId,
                                                                                                     branchId
                                                                                                     );

            if (preApprovalViewData == null)
            {
                preApprovalViewData = new PreApprovalViewData {
                    PreApprovalViewItem = new List <PreApprovalViewItem>(), TotalItems = 0, TotalPages = 0
                };
            }

            PreApprovalViewModel preApprovalViewModel = new PreApprovalViewModel
            {
                ActivityTypeList = new List <ActivityType>(Enum.GetValues(typeof(ActivityType)).Cast <ActivityType>()),
                PreApprovalItems = preApprovalViewData.PreApprovalViewItem,
                PageCount        = preApprovalViewData.TotalPages,
                TotalItems       = preApprovalViewData.TotalItems
            };

            PreApprovalGridHelper.ProcessPagingOptions(preApprovalListState, preApprovalViewModel);
            PreApprovalGridHelper.ApplyClassCollection(preApprovalViewModel);

            return(preApprovalViewModel);
        }
        public ActionResult RetrieveSmartGfeData(ManageFeesViewModel model)
        {
            ModelState.Clear();
            var loan = LoanServiceFacade.RetrieveLoan(model.TitleAndEscrow.LoanId, false, model.TitleAndEscrow.UserAccountId);

            var costGroupNumber11      = model.TitleAndEscrow.CostGroups.First(c => c.CostGroupNumber == 11);
            var costGroupNumber12      = model.TitleAndEscrow.CostGroups.First(c => c.CostGroupNumber == 12);
            var closingCostRequestId   = IntegrationLogServiceFacade.GetClosingCorpXmlForLoanId(model.TitleAndEscrow.LoanId, model.TitleAndEscrow.UserAccountId);
            var defaultCostCalculation = new DefaultCostCalculation()
            {
                LoanId = model.TitleAndEscrow.LoanId,
                ClosingCostRequestId  = closingCostRequestId,
                FeeProvider           = model.TitleAndEscrow.FeeProvider,
                MortgageType          = loan.MortgageType,
                PropertyValue         = loan.SubjectProperty.CurrentEstimatedValue.HasValue ? ( decimal )loan.SubjectProperty.CurrentEstimatedValue : 0,
                LoanAmount            = ( decimal )loan.BaseLoanAmount,
                StateName             = loan.SubjectProperty.Address == null ? null : loan.SubjectProperty.Address.StateName,
                PropertyType          = loan.SubjectProperty.PropertyType,
                InvestorName          = loan.InvestorName,
                CompanyProfile        = CompanyProfileServiceFacade.RetrieveCompanyProfile(),
                LoanTransactionTypeId = loan.LoanType
            };

            costGroupNumber11 = CostServiceFacade.RetrieveCostFromSmartGfe(defaultCostCalculation, model.TitleAndEscrow.UserAccountId, costGroupNumber11);
            costGroupNumber12 = CostServiceFacade.RetrieveCostFromSmartGfe(defaultCostCalculation, model.TitleAndEscrow.UserAccountId, costGroupNumber12);
            ManageFeesHelper.PreselectDefaultCosts(costGroupNumber11);
            ManageFeesHelper.PreselectDefaultCosts(costGroupNumber12);
            var group1100Index = model.TitleAndEscrow.CostGroups.FindIndex(g => g.CostGroupNumber == 11);

            model.TitleAndEscrow.CostGroups.RemoveAt(group1100Index);
            model.TitleAndEscrow.CostGroups.Insert(group1100Index, costGroupNumber11);
            var group1200Index = model.TitleAndEscrow.CostGroups.FindIndex(g => g.CostGroupNumber == 12);

            model.TitleAndEscrow.CostGroups.RemoveAt(group1200Index);
            model.TitleAndEscrow.CostGroups.Insert(group1200Index, costGroupNumber12);

            var itemize = GeneralSettingsServiceFacade.RetrieveStatusByGeneralSettingsName("Itemize Lender Credit", Guid.Empty, 0);

            LoanHelper.PerformPTCCalculationsForTitleEscrow(model.TitleAndEscrow.CostGroups, itemize);
            ManageFeesHelper.PopulateComboBoxes(model);
            ManageFeesHelper.SetTitleAndEscrowModel(model);
            return(PartialView("Commands/ManageFees/_manageFeeSmartGfeSection", model));
        }
        public JsonResult UpdateCostClosingDate(String loanId, String closingDate)
        {
            try
            {
                if (string.IsNullOrEmpty(loanId) || string.IsNullOrEmpty(closingDate))
                {
                    throw new ArgumentNullException("Loan Id and Closing Date are required");
                }

                int      userAccountId      = IdentityManager.GetUserAccountId();
                Guid     loanIdGuid         = new Guid(loanId);
                DateTime enteredClosingDate = DateTime.Parse(closingDate);

                UserAccount loggedUser         = ( UserAccount )System.Web.HttpContext.Current.Session[SessionHelper.UserData];
                var         closingDateHistory = new ClosingDateHistory
                {
                    ClosingDate  = enteredClosingDate,
                    DateOfChange = DateTime.Now,
                    LoanId       = loanIdGuid,
                    UserName     = loggedUser.Party.FirstName + " " + loggedUser.Party.LastName
                };

                LoanServiceFacade.UpdateManuallyEnteredCloseDate(loanIdGuid, true, userAccountId);
                LoanServiceFacade.UpdateLoanClosingDate(loanIdGuid, enteredClosingDate, userAccountId);
                CostServiceFacade.UpdateCostsAndClosingDate(loanIdGuid, enteredClosingDate, userAccountId);
                LoanServiceFacade.CreateClosingDateHistory(closingDateHistory, userAccountId);


                var model = ManageFeesHelper.GetCostByLoanId(loanIdGuid, loggedUser, HttpContext);

                var group901  = model.CostGroups.FirstOrDefault(x => x.CostGroupNumber == 90).Costs.FirstOrDefault(x => x.HUDLineNumber == 901);
                var group1002 = model.CostGroups.FirstOrDefault(x => x.CostGroupNumber == 10).Costs.FirstOrDefault(x => x.HUDLineNumber == 1002);
                var group1004 = model.CostGroups.FirstOrDefault(x => x.CostGroupNumber == 10).Costs.FirstOrDefault(x => x.HUDLineNumber == 1004);

                int isClosingDateChanged = model.HasClosingDateHistory ? 1 : 0;
                return(Json(new { success = true, group901 = group901, group1002 = group1002, group1004 = group1004, isClosingDateChanged = isClosingDateChanged }));
            }
            catch (Exception exception)
            {
                TraceHelper.Error(TraceCategory.LoanCenter, "_closingcosts.cshtml::UpdateCostClosingDate", exception, Guid.Empty, IdentityManager.GetUserAccountId());
                return(Json(new { success = false }));
            }
        }
        public static void SetTitleAndEscrowModel(ManageFeesViewModel model)
        {
            var feeTitles801        = Enum.GetValues(typeof(FeeTitles801)).Cast <FeeTitles801>().Select(title => title.GetStringValue()).ToList <string>();
            var feeTitles804To820   = Enum.GetValues(typeof(FeeTitles804To820)).Cast <FeeTitles804To820>().Select(title => title.GetStringValue()).ToList <string>();
            var feeTitles900        = Enum.GetValues(typeof(FeeTitles900)).Cast <FeeTitles900>().Select(title => title.GetStringValue()).ToList <string>();
            var feeTitles1000       = Enum.GetValues(typeof(FeeTitles1000)).Cast <FeeTitles1000>().Select(title => title.GetStringValue()).ToList <string>();
            var feeTitles1100       = Enum.GetValues(typeof(FeeTitles1100)).Cast <FeeTitles1100>().Select(title => title.GetStringValue()).ToList <string>();
            var feeTitles1200       = Enum.GetValues(typeof(FeeTitles1200)).Cast <FeeTitles1200>().Select(title => title.GetStringValue()).ToList <string>();
            var feeTitles1302To1307 = Enum.GetValues(typeof(FeeTitles1302To1307)).Cast <FeeTitles1302To1307>().Select(title => title.GetStringValue()).ToList <string>();
            var feeTitles1308To1311 = Enum.GetValues(typeof(FeeTitles1308To1311)).Cast <FeeTitles1308To1311>().Select(title => title.GetStringValue()).ToList <string>();

            PrepareFeeTitlesDropdown(feeTitles801);
            model.FeeTitles801 = feeTitles801;

            PrepareFeeTitlesDropdown(feeTitles804To820);
            model.FeeTitles804To820 = feeTitles804To820;

            PrepareFeeTitlesDropdown(feeTitles900);
            model.FeeTitles900 = feeTitles900;

            PrepareFeeTitlesDropdown(feeTitles1000);
            model.FeeTitles1000 = feeTitles1000;

            PrepareFeeTitlesDropdown(feeTitles1100);
            model.FeeTitles1100 = feeTitles1100;

            PrepareFeeTitlesDropdown(feeTitles1200);
            model.FeeTitles1200 = feeTitles1200;

            PrepareFeeTitlesDropdown(feeTitles1302To1307);
            model.FeeTitles1302To1307 = feeTitles1302To1307;

            PrepareFeeTitlesDropdown(feeTitles1308To1311);
            model.FeeTitles1308To1311 = feeTitles1308To1311;

            var leadSource = LoanServiceFacade.RetrieveHearAboutUs(model.TitleAndEscrow.LoanId);

            model.LeadSourceInformation = leadSource != null ? leadSource.LeadSourceId + " " + leadSource.Description : String.Empty;
            model.TitleInformation      = ConciergeWorkQueueServiceFacade.ExecuteSPGetBorrowerData("GetBorrowerData", model.TitleAndEscrow.LoanId, model.TitleAndEscrow.UserAccountId);
        }
        public static OrderDeliveredForReviewViewModel RetrieveOrderDeliveredForReviewViewModel(OrderDeliveredForReviewListState orderDeliveredForReviewListState, List <int> userAccountIds, int userAccountId, Guid companyId, int channelId, int divisionId, Guid branchId, string searchTerm = null)
        {
            if (orderDeliveredForReviewListState == null)
            {
                orderDeliveredForReviewListState = new OrderDeliveredForReviewListState();
            }

            if (userAccountIds == null)
            {
                userAccountIds = new List <Int32>();
            }

            DeliveredForReviewViewData deliveredForReviewViewData = LoanServiceFacade.RetrieveOrderDeliveredForReviewLoans(userAccountIds,
                                                                                                                           orderDeliveredForReviewListState.CurrentPage,
                                                                                                                           orderDeliveredForReviewListState.SortColumn.GetStringValue(),
                                                                                                                           orderDeliveredForReviewListState.SortDirection,
                                                                                                                           orderDeliveredForReviewListState.BoundDate,
                                                                                                                           orderDeliveredForReviewListState.AppraisalOrderStatus,
                                                                                                                           userAccountId,
                                                                                                                           searchTerm, companyId, channelId, divisionId, branchId);

            if (deliveredForReviewViewData == null)
            {
                deliveredForReviewViewData = new DeliveredForReviewViewData {
                    DeliveredForReviewOrders = new List <DeliveredForReviewView>(), TotalItems = 0, TotalPages = 0
                };
            }

            OrderDeliveredForReviewViewModel orderDeliveredForReviewViewModel = new OrderDeliveredForReviewViewModel
            {
                DeliveredForReviewOrders = deliveredForReviewViewData.DeliveredForReviewOrders,
                PageCount  = deliveredForReviewViewData.TotalPages,
                TotalItems = deliveredForReviewViewData.TotalItems
            };

            OrderDeliveredForReviewGridHelper.ProcessPagingOptions(orderDeliveredForReviewListState, orderDeliveredForReviewViewModel);
            OrderDeliveredForReviewGridHelper.ApplyClassCollection(orderDeliveredForReviewViewModel);

            return(orderDeliveredForReviewViewModel);
        }
Ejemplo n.º 28
0
        private void LoadDisclosureSummary(AppraisalViewModel userAppraisalViewModel, Guid loanId, UserAccount user)
        {
            DisclosuresSummaryInfo disclosuresSummaryInfo = DocumentsServiceFacade.RetrieveDisclosuresSummaryInfo(loanId, user.UserAccountId);

            userAppraisalViewModel.DisclosuresSummaryInfo = disclosuresSummaryInfo;

            var channel = CompanyProfileServiceFacade.GetChannelByChannelId(userAppraisalViewModel.Loan.ChannelId);

            var activateOrderAppraisal = false;

            if (channel != null && channel.ActivateOrderAppraisalSettings != null)
            {
                switch (channel.ActivateOrderAppraisalSettings.DisclosuresESignTriggerType)
                {
                case (int)OrderAppraisalTriggerEnum.FirstIntentToProceed:
                    IntegrationsSettings integrationSettings = LoanServiceFacade.RetrieveIntegrationsSettings(user.UserAccountId);
                    activateOrderAppraisal = (disclosuresSummaryInfo.IntentToProceedReceivedBorrower != null && disclosuresSummaryInfo.IntentToProceedReceivedCoBorrower != null) || (disclosuresSummaryInfo.IntentToProceedReceivedBorrower != null && integrationSettings != null && !integrationSettings.AllBorrowersMustESign);
                    break;

                case (int)OrderAppraisalTriggerEnum.LastIntentToProceed:
                    activateOrderAppraisal = DocumentsServiceFacade.CheckItpSetForAllLoanApplications(loanId, user.UserAccountId);
                    break;

                case (int)OrderAppraisalTriggerEnum.GFEandDisclosureActivity:
                    var activity = ActivitiesServiceFacade.RetrieveActivity(loanId, ActivityType.ReviewDisclosures, user.UserAccountId);
                    activateOrderAppraisal = channel.ActivateOrderAppraisalSettings.DisclosuresESignStatus == (int)ActivityStatus.Completed || channel.ActivateOrderAppraisalSettings.DisclosuresESignStatus == (int)ActivityStatus.Submitted;
                    if (((int)activity.Status == channel.ActivateOrderAppraisalSettings.DisclosuresESignStatus && channel.ActivateOrderAppraisalSettings.DisclosuresESignStatus == (int)ActivityStatus.Submitted) || activity.Status == ActivityStatus.Completed)
                    {
                        activateOrderAppraisal = true;
                    }
                    break;
                }
            }

            userAppraisalViewModel.IsAppraisalDisabled = !activateOrderAppraisal;
        }
        public static TitleAndEscrow GetCostByLoanId(Guid loanId, UserAccount user, HttpContextBase httpContext)
        {
            if (user == null)
            {
                return(new TitleAndEscrow());
            }

            int userAccountId = user.UserAccountId;

            List <Cost> costs = CostServiceFacade.GetManageFeesCosts(loanId, MortgageType.Conventional, LoanTransactionType.Refinance, Guid.Empty, Guid.Empty, -1);

            TitleAndEscrow titleAndEscrow = LoanServiceFacade.RetrieveTitleAndEscrowDetails(loanId, userAccountId);

            if (titleAndEscrow == null || titleAndEscrow.CostGroups == null || titleAndEscrow.CostGroups.Count == 0)
            {
                return(null);
            }

            if (costs != null && !titleAndEscrow.IncludeTaxesAndInsurances)
            {
                costs = costs.Where(c => c.HUDLineNumber != 1002 && c.HUDLineNumber != 1004).ToList();
            }

            var file = DocumentsServiceFacade.GetLatestFileByLoanIdAndDocumentClass(loanId, DocumentClass.SmartGFEComplianceCertificate, userAccountId);

            if (file != null && file.FileStoreItemId != Guid.Empty)
            {
                titleAndEscrow.SmartGfeDocumentLink = HttpUtility.UrlEncode(EncryptionHelper.EncryptRijndael(file.FileStoreItemId.ToString(), EncriptionKeys.Default));
                if (!titleAndEscrow.SmartGFEEnabled.HasValue)
                {
                    titleAndEscrow.SmartGFEEnabled = titleAndEscrow.SmartGFEEnabledOriginalValue = true;
                }
            }

            if ((user.Privileges != null && user.Privileges.Any(p => p.Category.Equals(( int )ActionCategory.LockFee))) ||
                (user.Roles != null && user.Roles.Any(r => r.Privileges.Any(p => p.Category.Equals(( int )ActionCategory.LockFee)))))
            {
                titleAndEscrow.IsAuthorizedToLockFee = true;
            }

            foreach (var costGroup in titleAndEscrow.CostGroups)
            {
                if (costGroup.Costs == null)
                {
                    continue;
                }

                foreach (var cost in costGroup.Costs)
                {
                    if (costs != null)
                    {
                        var loanCost = costs.FirstOrDefault(c => c.HUDLineNumber == cost.HUDLineNumber && (String.IsNullOrWhiteSpace(cost.SubHUDLineNumber) || (c.SubHUDLineNumber == cost.SubHUDLineNumber)));
                        if (loanCost != null)
                        {
                            cost.CostId            = loanCost.CostId;
                            cost.Amount            = loanCost.Amount;
                            cost.FromBorrowerFunds = loanCost.Amount;
                            if (loanCost.Amount != 0)
                            {
                                cost.IsAprCost = loanCost.IsAprCost;
                            }
                            cost.CostId              = loanCost.CostId;
                            cost.PaidBy              = loanCost.PaidBy;
                            cost.PaidTo              = loanCost.PaidTo;
                            cost.PocAmount           = loanCost.PocAmount;
                            cost.PtcAmount           = loanCost.PtcAmount;
                            cost.When                = loanCost.PocAmount > 0 ? "O" : "T";
                            cost.Name                = costGroup.CostGroupNumber != 12 ? loanCost.Name : RetrieveDisplayNameForGroup20(loanCost.Name);
                            cost.SmartGfeRequestType = loanCost.SmartGfeRequestType;
                            cost.Provider            = loanCost.Provider;
                            cost.IsLocked            = loanCost.IsLocked;
                            cost.Percent             = loanCost.Percent;
                            cost.Payee               = loanCost.Payee;

                            if (cost.HUDLineNumber == 901)
                            {
                                DateTime?closingDate = titleAndEscrow.ClosingDate;
                                if (closingDate.HasValue)
                                {
                                    int interestDays = Calculator.Calculator.CalculateInterestDays(closingDate.Value);

                                    cost.ClosingDate   = closingDate.Value.ToString("MM/dd/yyyy");
                                    cost.ClosingDateTo = closingDate.Value.AddDays(interestDays - 1).ToString("MM/dd/yyyy");
                                    cost.InterestDays  = interestDays;
                                    cost.InterestRate  = loanCost.Amount / interestDays;
                                }
                            }

                            // Set default MonthsToBePaid to 1, in case that stored DB value is -1
                            if (loanCost.MonthsToBePaid == -1 && loanCost.Amount > 0)
                            {
                                loanCost.MonthsToBePaid = 1;
                            }

                            if (loanCost.MonthsToBePaid > 0)
                            {
                                cost.MonthsToBePaid = loanCost.MonthsToBePaid;
                                cost.YearsToBePaid  = ( int )Math.Ceiling(( double )cost.MonthsToBePaid / 12);
                            }
                        }

                        cost.OldAmount = cost.Amount;
                    }
                }
            }


            if (httpContext.Session[SessionHelper.CurrentLoanIdForBusinessContact] is Guid && ( Guid )httpContext.Session[SessionHelper.CurrentLoanIdForBusinessContact] == loanId)
            {
                if (httpContext.Session[SessionHelper.CurrentBusinessContactBuyerAgent] != null)
                {
                    titleAndEscrow.BuyerAgent = httpContext.Session[SessionHelper.CurrentBusinessContactBuyerAgent].ToString();
                }

                if (httpContext.Session[SessionHelper.CurrentBusinessContactSellerAgent] != null)
                {
                    titleAndEscrow.SellerAgent = httpContext.Session[SessionHelper.CurrentBusinessContactSellerAgent].ToString();
                    // If the Agent information is the same for both only display a single instance on row 701
                    if (titleAndEscrow.SellerAgent.ToLower() == titleAndEscrow.BuyerAgent.ToLower())
                    {
                        titleAndEscrow.SellerAgent = String.Empty;
                    }
                }
            }
            else
            {
                var realtor = BusinessContactServiceFacade.RetrieveBusinessContactByTypeAndLoan(BusinessContactCategory.BuyerAgent, loanId);
                if (realtor != null && !String.IsNullOrEmpty(realtor.CompanyName))
                {
                    titleAndEscrow.BuyerAgent = realtor.CompanyName;
                }

                realtor = BusinessContactServiceFacade.RetrieveBusinessContactByTypeAndLoan(BusinessContactCategory.SellerAgent, loanId);
                if (realtor != null && !String.IsNullOrEmpty(realtor.CompanyName))
                {
                    titleAndEscrow.SellerAgent = realtor.CompanyName;
                }
            }

            return(titleAndEscrow);
        }
        public JsonResult GetLoanNumber(Guid loanId)
        {
            ConciergeIdAndLoanNumber toReturn = LoanServiceFacade.RetrieveConciergeIdAndLoanNumber(loanId, AccountHelper.GetUserAccountId( ));

            return(Json(toReturn, JsonRequestBehavior.AllowGet));
        }