示例#1
0
        public static void ProcessPagingOptions(NewLoanApplicationListState newLoanApplicationListState, NewLoanApplicationViewModel newLoanApplicationViewModel)
        {
            if (newLoanApplicationViewModel.PageCount % 10 == 0)
            {
                newLoanApplicationViewModel.PageGroups = (newLoanApplicationViewModel.PageCount / 10);
            }
            else
            {
                newLoanApplicationViewModel.PageGroups = (newLoanApplicationViewModel.PageCount / 10) + 1;
            }

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

            newLoanApplicationViewModel.CurrentPage = newLoanApplicationListState.CurrentPage;

            if (newLoanApplicationViewModel.CurrentPage % 10 != 0)
            {
                newLoanApplicationViewModel.StartPage = ( int )(newLoanApplicationViewModel.CurrentPage / 10) * 10 + 1;
                if ((( int )((newLoanApplicationViewModel.CurrentPage) / 10) + 1) == newLoanApplicationViewModel.PageGroups)
                {
                    newLoanApplicationViewModel.EndPage      = ( int )(newLoanApplicationViewModel.CurrentPage / 10) * 10 + newLoanApplicationViewModel.LastPageItems;
                    newLoanApplicationViewModel.LastPageDots = true;
                }
                else
                {
                    newLoanApplicationViewModel.EndPage      = ( int )(newLoanApplicationViewModel.CurrentPage / 10) * 10 + 10;
                    newLoanApplicationViewModel.LastPageDots = false;
                }
            }
            else
            {
                newLoanApplicationViewModel.StartPage = ( int )((newLoanApplicationViewModel.CurrentPage - 1) / 10) * 10 + 1;
                if ((( int )((newLoanApplicationViewModel.CurrentPage - 1) / 10) + 1) == newLoanApplicationViewModel.PageGroups)
                {
                    newLoanApplicationViewModel.EndPage      = ( int )(newLoanApplicationViewModel.CurrentPage / 10) * 10;
                    newLoanApplicationViewModel.LastPageDots = true;
                }
                else
                {
                    newLoanApplicationViewModel.EndPage      = ( int )((newLoanApplicationViewModel.CurrentPage - 1) / 10) * 10 + 10;
                    newLoanApplicationViewModel.LastPageDots = false;
                }
            }
        }
        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);
        }