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);
        }
예제 #2
0
        public static void ProcessPagingOptions(AlertsListState alertsListState, AlertsViewModel alertsViewModel)
        {
            if (alertsViewModel.PageCount % 10 == 0)
            {
                alertsViewModel.PageGroups = (alertsViewModel.PageCount / 10);
            }
            else
            {
                alertsViewModel.PageGroups = (alertsViewModel.PageCount / 10) + 1;
            }

            alertsViewModel.PageGroups = ( int )alertsViewModel.PageGroups;
            if (alertsViewModel.PageCount % 10 != 0)
            {
                alertsViewModel.LastPageItems = alertsViewModel.PageCount % 10;
            }
            else
            {
                alertsViewModel.LastPageItems = 10;
            }

            alertsViewModel.CurrentPage = alertsListState.CurrentPage;

            if (alertsViewModel.CurrentPage % 10 != 0)
            {
                alertsViewModel.StartPage = ( int )(alertsViewModel.CurrentPage / 10) * 10 + 1;
                if ((( int )((alertsViewModel.CurrentPage) / 10) + 1) == alertsViewModel.PageGroups)
                {
                    alertsViewModel.EndPage      = ( int )(alertsViewModel.CurrentPage / 10) * 10 + alertsViewModel.LastPageItems;
                    alertsViewModel.LastPageDots = true;
                }
                else
                {
                    alertsViewModel.EndPage      = ( int )(alertsViewModel.CurrentPage / 10) * 10 + 10;
                    alertsViewModel.LastPageDots = false;
                }
            }
            else
            {
                alertsViewModel.StartPage = ( int )((alertsViewModel.CurrentPage - 1) / 10) * 10 + 1;
                if ((( int )((alertsViewModel.CurrentPage - 1) / 10) + 1) == alertsViewModel.PageGroups)
                {
                    alertsViewModel.EndPage      = ( int )(alertsViewModel.CurrentPage / 10) * 10;
                    alertsViewModel.LastPageDots = true;
                }
                else
                {
                    alertsViewModel.EndPage      = ( int )((alertsViewModel.CurrentPage - 1) / 10) * 10 + 10;
                    alertsViewModel.LastPageDots = false;
                }
            }
        }