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);
        }
        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);
        }
        public static PipelineViewModel RetrievePipelineViewModel(PipelineListState pipelineListState, List <int> userAccountIds, int userAccountId, Guid companyId, int channelId, int divisionId, Guid branchId, string searchTerm = null)
        {
            if (pipelineListState == null)
            {
                pipelineListState = new PipelineListState();
            }

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

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

            PipelineViewData pipelineViewData = LoanServiceFacade.RetrievePipelineItemsView(userAccountIds,
                                                                                            pipelineListState.CurrentPage,
                                                                                            pipelineListState.SortColumn.GetStringValue(),
                                                                                            pipelineListState.SortDirection,
                                                                                            userAccountId,
                                                                                            searchTerm,
                                                                                            pipelineListState.ActivityTypeFilter,
                                                                                            pipelineListState.BoundDate,
                                                                                            pipelineListState.LoanPurposeFilter,
                                                                                            isOnLineUser,
                                                                                            companyId,
                                                                                            channelId,
                                                                                            divisionId,
                                                                                            branchId
                                                                                            );

            if (pipelineViewData == null)
            {
                pipelineViewData = new PipelineViewData {
                    PipelineItems = new List <PipelineViewItem>(), TotalItems = 0, TotalPages = 0
                };
            }
            // Set paging numbers
            else if (userAccountIds.Any())
            {
                pipelineViewData.TotalItems = pipelineViewData.TotalItems;
                pipelineViewData.TotalPages = pipelineViewData.TotalItems / 10;
                if ((pipelineViewData.TotalItems % 10) != 0)
                {
                    pipelineViewData.TotalPages++;
                }
            }
            for (int i = 0; i < pipelineViewData.PipelineItems.Count(); i++)
            {
                if (pipelineViewData.PipelineItems[i].PipelineViewItems.Count > 0)
                {
                    DataForShortProductDescription data =
                        LoanServiceFacade.RetrieveDataForShortProductDescription(pipelineViewData.PipelineItems[i].PipelineViewItems[0].LoanId);

                    pipelineViewData.PipelineItems[i].PipelineViewItems[0].ProgramName = LoanHelper.FormatShortProductDescription(pipelineViewData.PipelineItems[i].PipelineViewItems[0].IsHarp,
                                                                                                                                  EnumHelper.GetStringValue((AmortizationType)data.AmortizationType),
                                                                                                                                  data.LoanTerm,
                                                                                                                                  data.FixedRateTerm,
                                                                                                                                  EnumHelper.GetStringValue((MortgageType)data.MortgageType));
                }
            }
            PipelineViewModel pipelineViewModel = new PipelineViewModel
            {
                ActivityTypeList   = CommonHelper.RetrieveActivityListForQueueFilter(),
                LoanPurposeList    = new List <LoanTransactionType>(Enum.GetValues(typeof(LoanTransactionType)).Cast <LoanTransactionType>().Skip(1)),
                BorrowerStatusList = new List <BorrowerStatusType>(Enum.GetValues(typeof(BorrowerStatusType)).Cast <BorrowerStatusType>().Skip(1)),
                PipelineItems      = pipelineViewData.PipelineItems,
                PageCount          = pipelineViewData.TotalPages,
                TotalItems         = pipelineViewData.TotalItems
            };

            PipelineGridHelper.ProcessPagingOptions(pipelineListState, pipelineViewModel);
            PipelineGridHelper.ApplyClassCollection(pipelineViewModel);

            return(pipelineViewModel);
        }