public async Task <IPage <SimpleDocument <T> > > PageAsync(int pageSize, byte[] pagingState, Guid?tenantId = null, MetaData metaData = null) { if (metaData == null) { return(await base.PageAsync(pageSize, pagingState, tenantId)); } byte[] currentPagingState = pagingState; PagingState ps = pagingState.DeserializePageState(); var records = await RetrieveAsync(tenantId); records = Filter(records, metaData); var slice = records.Skip(ps.CurrentIndex).Take(pageSize).ToList(); if (slice.Count < pageSize) { // we are at the end pagingState = null; } else { ps.CurrentIndex += pageSize; pagingState = ps.Serialize(); } var page = new PageProxy <SimpleDocument <T> >(currentPagingState, pagingState, slice); return(page); }
public async Task <IActionResult> Index(GetProvidersForFeedbackRequest request, int pageIndex = PagingState.DefaultPageIndex) { var idClaim = HttpContext.User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier); var pagingState = await _sessionService.Get <PagingState>($"{idClaim.Value}_PagingState"); if (null == pagingState) { pagingState = new PagingState(); } pagingState.PageIndex = pageIndex; await _sessionService.Set($"{idClaim.Value}_PagingState", pagingState); var model = await _trainingProviderService.GetTrainingProviderSearchViewModel( request.EncodedAccountId, pagingState.SelectedProviderName, pagingState.SelectedFeedbackStatus, pagingState.PageSize, pagingState.PageIndex, pagingState.SortColumn, pagingState.SortDirection); model.ChangePageAction = nameof(Index); ViewBag.EmployerAccountsHomeUrl = _urlBuilder.AccountsLink("AccountsHome", request.EncodedAccountId); await _sessionService.Set($"{idClaim.Value}_ProviderCount", model.TrainingProviders.TotalRecordCount); return(View(model)); }
public AlertList CreateAlertList(IList <AAlert_Alert> mSummaries, PagingState pagingState) { var summaries = mSummaries.Select(r => CreateAlertListItem(r)).ToList(); var sortFunction = GetSortFunction(pagingState.Sort); var sortedSummaries = sortFunction != null ? pagingState.Descending ? summaries.OrderByDescending(sortFunction).ToList() : summaries.OrderBy(sortFunction).ToList() : summaries; int pageSize = PagingState.PageSize; int pageNumber = WebMath.GetPageNumber(pagingState.Page, sortedSummaries.Count, pageSize); var pagedAlerts = sortedSummaries.ToPagedList(pageNumber, pageSize); var(acknowledged, recordCount) = ParsePagingStateFilter(pagingState.Filter); var model = new AlertList() { Items = pagedAlerts, Filter = new AlertListFilter() { Acknowledged = ToString(acknowledged), RecordCount = recordCount, AcknowledgedList = CreateNullableBooleanList(), RecordCountList = CreateRecordCountList() } }; return(model); }
public void paging_state_conversions() { PagingState pagingStateExpected = new PagingState() { CurrentIndex = 1234 }; var bytes = pagingStateExpected.Serialize(); var pagingState = bytes.DeserializePageState(); pagingState.ShouldBe(pagingStateExpected); var psString = Convert.ToBase64String(bytes); bytes = Convert.FromBase64String(psString); pagingState = bytes.DeserializePageState(); pagingState.ShouldBe(pagingStateExpected); var urlEncodedPagingState = WebUtility.UrlEncode(psString); var psStringUrlDecoded = WebUtility.UrlDecode(urlEncodedPagingState); psStringUrlDecoded.ShouldBe(psString); bytes = Convert.FromBase64String(psStringUrlDecoded); pagingState = bytes.DeserializePageState(); pagingState.ShouldBe(pagingStateExpected); }
/// <summary> /// Call the next page request when there is another page of data. /// </summary> /// <param name="token"></param> /// <returns>The task object that represents the results of this asynchronous operation.</returns> /// <exception cref="Microsoft.Graph.ServiceException">Thrown when the service encounters an error with /// a request.</exception> private async Task InterpageIterateAsync(CancellationToken token) { State = PagingState.InterpageIteration; // Get the next page if it is available and queue the items for processing. if (_currentPage.AdditionalData.TryGetValue(Constants.OdataInstanceAnnotations.NextLink, out object nextlink)) { // We need access to the NextPageRequest to call and get the next page. ICollectionPage<TEntity> doesn't define NextPageRequest. // We are making this dynamic so we can access NextPageRequest. dynamic page = _currentPage; // Call the MSGraph API to get the next page of results and set that page as the currentPage. _currentPage = await page.NextPageRequest.GetAsync(token).ConfigureAwait(false); // Add all of the items returned in the response to the queue. if (_currentPage.Count > 0) { foreach (TEntity entity in _currentPage) { _pageItemQueue.Enqueue(entity); } } } // Detect nextLink loop if (_currentPage.AdditionalData.TryGetValue(Constants.OdataInstanceAnnotations.NextLink, out object nextNextLink) && nextlink.Equals(nextNextLink)) { throw new ServiceException(new Error() { Message = $"Detected nextLink loop. Nextlink value: {Nextlink}" }); } }
public async Task <IActionResult> Filter(ProviderSearchViewModel postedModel) { var idClaim = HttpContext.User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier); var pagingState = await _sessionService.Get <PagingState>($"{idClaim.Value}_PagingState"); if (null == pagingState) { pagingState = new PagingState(); } pagingState.PageIndex = PagingState.DefaultPageIndex; // applying filter resets the paging pagingState.SelectedProviderName = postedModel.SelectedProviderName; pagingState.SelectedFeedbackStatus = postedModel.SelectedFeedbackStatus; await _sessionService.Set($"{idClaim.Value}_PagingState", pagingState); var model = await _trainingProviderService.GetTrainingProviderSearchViewModel( postedModel.EncodedAccountId, pagingState.SelectedProviderName, pagingState.SelectedFeedbackStatus, pagingState.PageSize, pagingState.PageIndex, pagingState.SortColumn, pagingState.SortDirection); ViewBag.EmployerAccountsHomeUrl = _urlBuilder.AccountsLink("AccountsHome", postedModel.EncodedAccountId); return(View("Index", model)); }
public async Task <IPage <T> > PageAsync( int pageSize, byte[] pagingState, Guid?tenantId = null) { byte[] currentPagingState = pagingState; PagingState ps = pagingState.DeserializePageState(); var records = await RetrieveAsync(tenantId); var slice = records.Skip(ps.CurrentIndex).Take(pageSize).ToList(); if (slice.Count < pageSize) { // we are at the end pagingState = null; } else { ps.CurrentIndex += pageSize; pagingState = ps.Serialize(); } var page = new PageProxy <T>(currentPagingState, pagingState, slice); return(page); }
private async Task <DesignSummaryListModel> GetDesignSummaryListModel(PagingState pagingState) { var svcDesignSummaryList = await DesignUserService.GetDesignSummariesAsync(GetUserId(), null, null); var model = ModelFactory.CreateDesignSummaryListModel(svcDesignSummaryList, pagingState); return(model); }
private async Task <KitSummaryListModel> GetKitSummaryListModelAsync(PagingState pagingState) { var svcKitSummaries = await ProjectUserService.GetProjectSummariesAsync(GetUserId(), null, null); var model = ModelFactory.CreateKitSummaryListModel(svcKitSummaries, pagingState); return(model); }
private async Task <LogEntryListModel> GetLogEntryListModel(PagingState pagingSate) { var svcLogEntries = await LogAdminService.GetLogEntriesAsync(pagingSate.Filter); var model = ModelFactory.CreateLogEntryListModel(svcLogEntries, pagingSate, LogAdminService); return(model); }
public OrderList CreateOrderList(IList <AOrder_OrderSummary> aSummaries, PagingState pagingState) { var summaries = aSummaries.Select(r => CreateOrderListItem(r)).ToList(); var sortFunction = GetSortFunction(pagingState.Sort); var sortedSummaries = sortFunction != null ? pagingState.Descending ? summaries.OrderByDescending(sortFunction).ToList() : summaries.OrderBy(sortFunction).ToList() : summaries; var pageSize = PagingState.PageSize; var pageNumber = WebMath.GetPageNumber(pagingState.Page, sortedSummaries.Count, pageSize); var pagedSummaries = sortedSummaries.ToPagedList(pageNumber, pageSize); var(orderNumber, orderDate, orderStatus, userName, recordCount) = ParsePagingStateFilter(pagingState.Filter); var model = new OrderList() { Items = pagedSummaries, Filter = new OrderListFilter() { OrderNumber = orderNumber, OrderDate = orderDate, UserName = userName, OrderStatus = orderStatus, RecordCount = recordCount, OrderStatusList = new List <SelectListItem> { new SelectListItem() { Text = "All", Value = MOrder_OrderStatus.MetaAll.ToString() }, new SelectListItem() { Text = "Pending", Value = MOrder_OrderStatus.Pending.ToString() }, new SelectListItem() { Text = "Submitted", Value = MOrder_OrderStatus.Submitted.ToString() }, new SelectListItem() { Text = "Fulfilling", Value = MOrder_OrderStatus.Fulfilling.ToString() }, new SelectListItem() { Text = "Closed", Value = MOrder_OrderStatus.Closed.ToString() } }, RecordCountList = CreateRecordCountList() } }; return(model); }
public async Task <ICollection <SimpleDocument <T> > > PageAsync(int pageSize, int page, Guid?tenantId = null, MetaData metaData = null) { PagingState ps = new PagingState() { CurrentIndex = pageSize * (page - 1) }; var pagingState = ps.Serialize(); return(await PageAsync(pageSize, pagingState, tenantId, metaData)); }
private async Task <EventLogList> GetFulfillmentEventLogListAsync(PagingState pagingState) { ModelFactory.ParseFilter(pagingState.Filter, out string unitOfWork, out string source); var aTrnsactionList = await EventAdminService.GetEventLogsAsync(unitOfWork, source != "*ANY"?source : null); var model = ModelFactory.CreateEventLogList(aTrnsactionList, pagingState); return(model); }
public async Task <IPage <SimpleDocument <Blog> > > PageAsync(int pageSize, int page, DateTime?timeStampLowerBoundary = default(DateTime?), DateTime?timeStampUpperBoundary = default(DateTime?), string[] categories = null, string[] tags = null) { PagingState ps = new PagingState() { CurrentIndex = pageSize * (page - 1) }; var pagingState = ps.Serialize(); return(await PageAsync(pageSize, pagingState, timeStampLowerBoundary, timeStampUpperBoundary, categories, tags)); }
public async Task <IPage <SimpleDocument <RazorLocation> > > PageAsync(int pageSize, int page, DateTime?timeStampLowerBoundary = default(DateTime?), DateTime?timeStampUpperBoundary = default(DateTime?)) { PagingState ps = new PagingState() { CurrentIndex = pageSize * (page - 1) }; var pagingState = ps.Serialize(); return(await PageAsync(pageSize, pagingState, timeStampLowerBoundary, timeStampUpperBoundary)); }
private async Task <TransactionList> GetFulfillmentTransactionListAsync(PagingState pagingState) { var(unitOfWork, source) = ModelFactory.ParsePagingStateFilter(pagingState.Filter); var aTrnsactionList = await TransactionAdminService.GetTransactionsAsync( unitOfWork, source != TransactionModelFactory.AnySource?source : null); var model = ModelFactory.CreateTransactionList(aTrnsactionList, pagingState); return(model); }
protected void Page_Load(object sender, EventArgs e) { _pagingState = new PagingState(this); if (!string.IsNullOrEmpty(AfterControlID)) { Control c = Parent.FindControl(AfterControlID); if (c != null) { c.PreRender += ReportNavigation_PreRender; } } }
public async Task <IActionResult> SortProviders(string encodedAccountId, string sortColumn, string sortDirection) { var idClaim = HttpContext.User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier); var pagingState = await _sessionService.Get <PagingState>($"{idClaim.Value}_PagingState"); if (null == pagingState) { pagingState = new PagingState(); } pagingState.SortColumn = sortColumn; pagingState.SortDirection = sortDirection; await _sessionService.Set($"{idClaim.Value}_PagingState", pagingState); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> ClearFilters(string encodedAccountId) { var idClaim = HttpContext.User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier); var pagingState = await _sessionService.Get <PagingState>($"{idClaim.Value}_PagingState"); if (null == pagingState) { pagingState = new PagingState(); } pagingState.SelectedProviderName = string.Empty; pagingState.SelectedFeedbackStatus = string.Empty; await _sessionService.Set($"{idClaim.Value}_PagingState", pagingState); return(RedirectToAction(nameof(Index))); }
public async Task <IPage <SimpleDocument <Blog> > > PageAsync(int pageSize, byte[] pagingState, DateTime?timeStampLowerBoundary = null, DateTime?timeStampUpperBoundary = null, string[] categories = null, string[] tags = null) { byte[] currentPagingState = pagingState; PagingState ps = pagingState.DeserializePageState(); var records = await RetrieveAsync(); records = records.OrderBy(o => o.Document.TimeStamp).ToList(); var predicate = PredicateBuilder.True <SimpleDocument <Blog> >(); if (timeStampLowerBoundary != null) { predicate = predicate.And(i => i.Document.TimeStamp >= timeStampLowerBoundary); } if (timeStampUpperBoundary != null) { predicate = predicate.And(i => i.Document.TimeStamp <= timeStampUpperBoundary); } // this is an AND that return an OR match for tags and categories. List <string> safeTagList = (tags == null) ? null : new List <string>(tags); List <string> safeCategoriesList = (categories == null) ? null : new List <string>(categories); predicate = predicate.And(i => DelegateContainsAnyInTagsOrCategories(i.Document, safeTagList, safeCategoriesList)); var filtered = records.Where(predicate.Compile()).Select(i => i); var slice = filtered.Skip(ps.CurrentIndex).Take(pageSize).ToList(); if (slice.Count < pageSize) { // we are at the end pagingState = null; } else { ps.CurrentIndex += pageSize; pagingState = ps.Serialize(); } var page = new PageProxy <SimpleDocument <Blog> >(currentPagingState, pagingState, slice); return(page); }
/// <summary> /// Iterate across the content of a a single results page with the callback. /// </summary> /// <returns>A boolean value that indicates whether the callback cancelled /// iterating across the page results or whether there are more pages to page. /// A return value of false indicates that the iterator should stop iterating.</returns> private bool IntrapageIterate() { State = PagingState.IntrapageIteration; while (_pageItemQueue.Count != 0) // && shouldContinue) { bool shouldContinue = _processPageItemCallback(_pageItemQueue.Dequeue()); // Cancel processing of items in the page and stop requesting more pages. if (!shouldContinue) { State = PagingState.Paused; return(shouldContinue); } } // There are more pages ready to be paged. if (_currentPage.AdditionalData.TryGetValue(Constants.OdataInstanceAnnotations.NextLink, out object nextlink)) { Nextlink = nextlink as string; return(true); } // There are no pages CURRENTLY ready to be paged. Attempt to call delta query later. else if (_currentPage.AdditionalData.TryGetValue(Constants.OdataInstanceAnnotations.DeltaLink, out object deltalink)) { Deltalink = deltalink as string; State = PagingState.Delta; Nextlink = string.Empty; // Setup deltalink request. Using dynamic to access the NextPageRequest. dynamic page = _currentPage; page.InitializeNextPageRequest(this._client, Deltalink); _currentPage = page; return(false); } // Paging has completed - no more nextlinks. else { State = PagingState.Complete; Nextlink = string.Empty; return(false); } }
public async Task GetMultiplePagesOfWords() { var paging = new PagingState(100); DateTime date = new DateTime(2013, 1, 1); // this date seems to return many pages var phrases = await service.GetTopPhrasesByDate(date, 1, paging); while (paging.Advance(phrases.Count())) { var phrase1 = phrases.FirstOrDefault(); phrases = await service.GetTopPhrasesByDate(date, 1, paging); var phrase2 = phrases.FirstOrDefault(); Assert.AreNotEqual(phrase1, phrase2); } Assert.IsTrue(paging.Page > 2); }
private async Task <UserList> GetUserList(PagingState pagingState) { (var role, var userName) = ModelFactory.ParseFilter(pagingState.Filter); if (role == UserModelFactory.AnyRole) { role = null; } var request = new AUser_GetUsers() { Role = role, UserName = userName }; var aUserSummaries = await UserAdminService.GetUsersAsync(request); var model = ModelFactory.CreateUserList(aUserSummaries.MSummaries.Summaries, pagingState); return(model); }
public async Task <IPage <SimpleDocument <RazorLocation> > > PageAsync(int pageSize, byte[] pagingState, DateTime?timeStampLowerBoundary = null, DateTime?timeStampUpperBoundary = null) { byte[] currentPagingState = pagingState; PagingState ps = pagingState.DeserializePageState(); var records = await RetrieveAsync(); records = records.OrderBy(o => o.Document.LastModified).ToList(); var predicate = PredicateBuilder.True <SimpleDocument <RazorLocation> >(); if (timeStampLowerBoundary != null) { predicate = predicate.And(i => i.Document.LastModified >= timeStampLowerBoundary); } if (timeStampUpperBoundary != null) { predicate = predicate.And(i => i.Document.LastModified <= timeStampUpperBoundary); } var filtered = records.Where(predicate.Compile()).Select(i => i); var slice = filtered.Skip(ps.CurrentIndex).Take(pageSize).ToList(); if (slice.Count < pageSize) { // we are at the end pagingState = null; } else { ps.CurrentIndex += pageSize; pagingState = ps.Serialize(); } var page = new PageProxy <SimpleDocument <RazorLocation> >(currentPagingState, pagingState, slice); return(page); }
private async Task <InventoryItemListModel> GetInventoryItemListModel(PagingState pagingState) { var svcInventoryItems = await InventoryAdminService.GetItemsAsync(); //if (!string.IsNullOrEmpty(pagingState.Search)) //{ // svcInventoryItems = svcInventoryItems.Where(r => r.Sku.Contains(pagingState.Search)).ToList(); //} if (pagingState.Filter == InventoryItemListModel.FILTER_LOW) { svcInventoryItems = svcInventoryItems.Where(r => r.Quantity < 10).ToList(); } else if (pagingState.Filter == InventoryItemListModel.FILTER_OUT) { svcInventoryItems = svcInventoryItems.Where(r => r.Quantity == 0).ToList(); } var model = ModelFactory.CreateInventoryItemListModel(svcInventoryItems, pagingState); return(model); }
public async Task <IPage <Client> > PageAsync(int pageSize, byte[] pagingState) { byte[] currentPagingState = pagingState; PagingState ps = pagingState.DeserializePageState(); var records = await RetrieveAsync(); records = records.OrderBy(o => o.Id).ToList(); var predicate = PredicateBuilder.True <ClientDocument>(); var filtered = records.Where(predicate.Compile()).Select(i => i); var slice = filtered.Skip(ps.CurrentIndex).Take(pageSize).ToList(); if (slice.Count < pageSize) { // we are at the end pagingState = null; } else { ps.CurrentIndex += pageSize; pagingState = ps.Serialize(); } List <Client> clientSlice = new List <Client>(); foreach (var item in slice) { var client = await item.MakeClientAsync(); clientSlice.Add(client); } var page = new PageProxy <Client>(currentPagingState, pagingState, clientSlice); return(page); }
public LogEntryListModel CreateLogEntryListModel(IReadOnlyList <ALog_LogEntry> svcLogEntries, PagingState pagingState, ILogAdminService logService) { var logEntries = svcLogEntries.Select(r => CreateLogEntryModel(r)).ToList(); IReadOnlyList <LogEntryModel> sortedLogEntries; var sortFunction = GetSortFunction(pagingState.Sort); sortedLogEntries = sortFunction != null ? pagingState.Descending ? logEntries.OrderByDescending(sortFunction).ToList() : logEntries.OrderBy(sortFunction).ToList() : logEntries; var pageSize = 10; var pageNumber = WebMath.GetPageNumber(pagingState.Page, sortedLogEntries.Count, pageSize); var pagedLogEntries = sortedLogEntries.ToPagedList(pageNumber, pageSize); var model = new LogEntryListModel() { LogEntries = pagedLogEntries, Filter = pagingState.Filter, Filters = new List <SelectListItem> { new SelectListItem() { Text = "All", Value = logService.ViewMode_All }, new SelectListItem() { Text = "Exception", Value = logService.ViewMode_Exception } } }; return(model); }
public InventoryItemListModel CreateInventoryItemListModel(IReadOnlyList <AInventory_InventoryItem> svcInventoryItems, PagingState pagingState) { var inventoryItems = new List <InventoryItemModel>(); foreach (var svcInventoryItem in svcInventoryItems) { var inventoryItemStocks = new List <InventoryItemStockModel>(); foreach (var svcInventoryItemStock in svcInventoryItem.InventoryItemStocks) { inventoryItemStocks.Add(new InventoryItemStockModel() { Id = svcInventoryItemStock.InventoryItemStockId.ToString(), UnitOfMeasure = svcInventoryItemStock.UnitOfMeasure, UnitCost = svcInventoryItemStock.UnitCost, StockDateTime = Locale.GetLocalTimeFromUtc(svcInventoryItemStock.StockDateTimeUtc), OriginalQuantity = svcInventoryItemStock.OriginalQuantity, CurrentQuantity = svcInventoryItemStock.CurrentQuantity }); } inventoryItems.Add(new InventoryItemModel() { Id = svcInventoryItem.Id.ToString(), TypeName = svcInventoryItem.Type, Sku = svcInventoryItem.Sku, Name = svcInventoryItem.Name, Manufacturer = svcInventoryItem.Manufacturer, Collection = svcInventoryItem.Collection, Quantity = svcInventoryItem.Quantity, ReservedQuantity = svcInventoryItem.ReservedQuantity, WebColor = svcInventoryItem.Color.WebColor, Stocks = inventoryItemStocks }); } IList <InventoryItemModel> sortedInventoryItems; var sortFunction = GetSortFunction(pagingState.Sort); sortedInventoryItems = sortFunction != null ? pagingState.Descending ? inventoryItems.OrderByDescending(sortFunction).ToList() : inventoryItems.OrderBy(sortFunction).ToList() : inventoryItems; var pageSize = 10; var pageNumber = WebMath.GetPageNumber(pagingState.Page, sortedInventoryItems.Count, pageSize); var pagedInventoryItems = sortedInventoryItems.ToPagedList(pageNumber, pageSize); var model = new InventoryItemListModel() { InventoryItems = pagedInventoryItems, Filter = pagingState.Filter ?? InventoryItemListModel.FILTER_ALL, Filters = new List <SelectListItem> { new SelectListItem() { Value = InventoryItemListModel.FILTER_ALL, Text = "All" }, new SelectListItem() { Value = InventoryItemListModel.FILTER_LOW, Text = "Low" }, new SelectListItem() { Value = InventoryItemListModel.FILTER_OUT, Text = "Out of Stock" } } }; return(model); }
public ReturnList CreateReturnListModel(IReadOnlyList <AReturn_ReturnSummary> aReturns, PagingState pagingState) { var summaries = aReturns.Select(r => CreateReturnDetailModel(r)).ToList(); var sortFunction = GetSortFunction(pagingState.Sort); var sortedSummaries = sortFunction != null ? pagingState.Descending ? summaries.OrderByDescending(sortFunction).ToList() : summaries.OrderBy(sortFunction).ToList() : summaries; var pageSize = PagingState.PageSize; var pageNumber = WebMath.GetPageNumber(pagingState.Page, sortedSummaries.Count, pageSize); var pagedSummaries = sortedSummaries.ToPagedList(pageNumber, pageSize); var(returnStatus, recordCount) = ParsePagingStateFilter(pagingState.Filter); var model = new ReturnList() { Items = pagedSummaries, Filter = new ReturnListFilter() { ReturnStatus = returnStatus, RecordCount = recordCount, ReturnStatusList = new List <SelectListItem> { new SelectListItem() { Text = "All", Value = MFulfillment_ReturnStatus.MetaAll.ToString() }, new SelectListItem() { Text = "Active", Value = MFulfillment_ReturnStatus.MetaActive.ToString() }, new SelectListItem() { Text = "Open", Value = MFulfillment_ReturnStatus.Open.ToString() }, new SelectListItem() { Text = "Posted", Value = MFulfillment_ReturnStatus.Posted.ToString() }, new SelectListItem() { Text = "Complete", Value = MFulfillment_ReturnStatus.Complete.ToString() }, new SelectListItem() { Text = "Cancelled", Value = MFulfillment_ReturnStatus.Cancelled.ToString() }, new SelectListItem() { Text = "Exception", Value = MFulfillment_ReturnStatus.Exception.ToString() } }, RecordCountList = CreateRecordCountList() } }; return(model); }
public KitSummaryListModel CreateKitSummaryListModel(UProject_ProjectSummaryList svcKits, PagingState pagingState) { var kitSummaries = new List <KitSummaryModel>(); foreach (var svcKitSummary in svcKits.ProjectSummaries) { var summary = new KitSummaryModel() { KitId = svcKitSummary.ProjectId, KitName = svcKitSummary.ProjectName }; kitSummaries.Add(summary); } IReadOnlyList <KitSummaryModel> sortedKitSummaries; var sortFunction = GetSortFunction(pagingState.Sort); sortedKitSummaries = sortFunction != null ? pagingState.Descending ? kitSummaries.OrderByDescending(sortFunction).ToList() : kitSummaries.OrderBy(sortFunction).ToList() : kitSummaries; int pageSize = 11; int pageNumber = WebMath.GetPageNumber(pagingState.Page, sortedKitSummaries.Count, pageSize); var pagedKitSummaries = sortedKitSummaries.ToPagedList(pageNumber, pageSize); var model = new KitSummaryListModel() { KitSummaries = pagedKitSummaries, HasDeletedKits = svcKits.HasDeletedProjects, Filter = pagingState.Filter, Filters = new List <SelectListItem> { new SelectListItem() { Text = "All", Value = "All" } }, RenameKit = new KitRenameModel() }; return(model); }