示例#1
0
        /// <summary>
        /// Registers Pagination returned by the service tier.  Use when there are multiple paged tables and you need to
        /// specify an id.
        /// </summary>
        public bool RegisterPagingStatus(string pagingId, PagingStatus pagination, PageRequestWithSort pagingRequest, string itemNamePlural, out ActionResult result)
        {
            string queryStringParameter = PagingConstants.QueryStringParameters.PageNumber;

            if (pagingId != PagingConstants.DefaultPagingId)
            {
                queryStringParameter += pagingId;
            }

            int correctPageNumber;

            if (IsPaginationInvalid(pagingRequest.PageNumber, pagination.TotalPages, out correctPageNumber))
            {
                var parameters = new KeyValuePair <string, string>(queryStringParameter, correctPageNumber.ToString());
                result = new RedirectResult(HttpContext.Request.Url.ChangeQueryString(parameters));
                return(false);
            }
            var viewModel = PagingViewModelGenerator.Generate(pagingId, pagination, pagingRequest);

            viewModel.ItemNamePlural          = itemNamePlural;
            ViewData["pagination" + pagingId] = viewModel;

            result = null;
            return(true);
        }
示例#2
0
        public void CanSerializePage()
        {
            IEnumerable <string> items = new[] { "1", "2", "3" };
            var paging = new PagingStatus(10, 1, 122);
            var page   = new Page <string>(items.ToList(), paging);

            var bytes  = SerializationHelper.ProtobufSerialize(page);
            var dspage = SerializationHelper.ProtobufDeserialize <Page <string> >(bytes);

            Assert.That(dspage.Items.Count() == 3);
            Assert.That(dspage.PagingStatus.PageSize == 10);
            Assert.That(dspage.PagingStatus.HasNextPage);
            Assert.That(dspage.PagingStatus.TotalPages == 13);
        }
示例#3
0
 public bool RegisterPagingStatus(PagingStatus pagination, PageRequestWithSort pagingRequest, string itemNamePlural, out ActionResult result)
 {
     return(RegisterPagingStatus(PagingConstants.DefaultPagingId, pagination, pagingRequest, itemNamePlural, out result));
 }
示例#4
0
 public bool RegisterPagingStatus(string pagingId, PagingStatus pagingStatus, PageRequestWithSort pagingRequest, out ActionResult overrideActionResult)
 {
     return(RegisterPagingStatus(pagingId, pagingStatus, pagingRequest, null, out overrideActionResult));
 }