public static void ProcessPagingOptions(OrderExceptionListState orderExceptionListState, OrderExceptionViewModel orderExceptionViewModel) { if (orderExceptionViewModel.PageCount % 10 == 0) { orderExceptionViewModel.PageGroups = (orderExceptionViewModel.PageCount / 10); } else { orderExceptionViewModel.PageGroups = (orderExceptionViewModel.PageCount / 10) + 1; } orderExceptionViewModel.PageGroups = ( int )orderExceptionViewModel.PageGroups; if (orderExceptionViewModel.PageCount % 10 != 0) { orderExceptionViewModel.LastPageItems = orderExceptionViewModel.PageCount % 10; } else { orderExceptionViewModel.LastPageItems = 10; } orderExceptionViewModel.CurrentPage = orderExceptionListState.CurrentPage; if (orderExceptionViewModel.CurrentPage % 10 != 0) { orderExceptionViewModel.StartPage = ( int )(orderExceptionViewModel.CurrentPage / 10) * 10 + 1; if ((( int )((orderExceptionViewModel.CurrentPage) / 10) + 1) == orderExceptionViewModel.PageGroups) { orderExceptionViewModel.EndPage = ( int )(orderExceptionViewModel.CurrentPage / 10) * 10 + orderExceptionViewModel.LastPageItems; orderExceptionViewModel.LastPageDots = true; } else { orderExceptionViewModel.EndPage = ( int )(orderExceptionViewModel.CurrentPage / 10) * 10 + 10; orderExceptionViewModel.LastPageDots = false; } } else { orderExceptionViewModel.StartPage = ( int )((orderExceptionViewModel.CurrentPage - 1) / 10) * 10 + 1; if ((( int )((orderExceptionViewModel.CurrentPage - 1) / 10) + 1) == orderExceptionViewModel.PageGroups) { orderExceptionViewModel.EndPage = ( int )(orderExceptionViewModel.CurrentPage / 10) * 10; orderExceptionViewModel.LastPageDots = true; } else { orderExceptionViewModel.EndPage = ( int )((orderExceptionViewModel.CurrentPage - 1) / 10) * 10 + 10; orderExceptionViewModel.LastPageDots = false; } } }
public static OrderExceptionViewModel RetrieveOrderExceptionViewModel(OrderExceptionListState orderExceptionListState, List <int> userAccountIds, int userAccountId, Guid companyId, int channelId, int divisionId, Guid branchId, string searchTerm = null) { if (orderExceptionListState == null) { orderExceptionListState = new OrderExceptionListState(); } if (userAccountIds == null) { userAccountIds = new List <Int32>(); } OrderExceptionViewData orderExceptionViewData = LoanServiceFacade.RetrieveOrderExceptionLoans(userAccountIds, orderExceptionListState.CurrentPage, orderExceptionListState.SortColumn.GetStringValue(), orderExceptionListState.SortDirection, orderExceptionListState.BoundDate, orderExceptionListState.ExceptionType, userAccountId, searchTerm, companyId, channelId, divisionId, branchId); if (orderExceptionViewData == null) { orderExceptionViewData = new OrderExceptionViewData { Exceptions = new List <OrderExceptionView>(), TotalItems = 0, TotalPages = 0 }; } OrderExceptionViewModel orderExceptionViewModel = new OrderExceptionViewModel { Exceptions = orderExceptionViewData.Exceptions, PageCount = orderExceptionViewData.TotalPages, TotalItems = orderExceptionViewData.TotalItems }; OrderExceptionGridHelper.ProcessPagingOptions(orderExceptionListState, orderExceptionViewModel); OrderExceptionGridHelper.ApplyClassCollection(orderExceptionViewModel); return(orderExceptionViewModel); }