Example #1
0
        private static PagingVm MapToCommonPagingVm <TResult, TSort>(this ResultSetSearchVm <TResult, TSort> result)
        {
            PagingVm pagingVm = new PagingVm();

            pagingVm.CurrentPage = result.PageNumber;
            pagingVm.PageSize    = ConfigurationManager.Instance.DefaultPageSize;
            pagingVm.TotalCount  = result.TotalCount;
            if (result.TotalCount > result.PageSize && pagingVm.CurrentPage <= pagingVm.TotalPages)
            {
                if (pagingVm.CurrentPage != 1)
                {
                    pagingVm.Pages.Add(new PageLinkVm
                    {
                        Css        = "first",
                        PageNumber = 1
                    });
                    pagingVm.Pages.Add(new PageLinkVm
                    {
                        Css        = "prev",
                        PageNumber = ((pagingVm.CurrentPage <= 1) ? 1 : (pagingVm.CurrentPage - 1))
                    });
                }
                int num  = ((pagingVm.TotalPages > pagingVm.TotalDisplay) ? pagingVm.TotalDisplay : pagingVm.TotalPages);
                int num2 = ((pagingVm.CurrentPage <= pagingVm.TotalDisplay - pagingVm.DisplayVector || pagingVm.TotalPages <= pagingVm.TotalDisplay) ? 1 : ((pagingVm.CurrentPage < pagingVm.TotalPages - pagingVm.DisplayVector) ? (pagingVm.CurrentPage - pagingVm.DisplayVector) : (pagingVm.TotalPages - pagingVm.TotalDisplay + 1)));
                for (int i = 0; i < num; i++)
                {
                    int num3 = i + num2;
                    pagingVm.Pages.Add(new PageLinkVm
                    {
                        InnerText  = num3.ToString(CultureInfo.InvariantCulture),
                        PageNumber = num3,
                        Css        = ((num3 == pagingVm.CurrentPage) ? "active" : null)
                    });
                }
                if (pagingVm.CurrentPage != pagingVm.TotalPages)
                {
                    pagingVm.Pages.Add(new PageLinkVm
                    {
                        Css        = "next",
                        PageNumber = ((pagingVm.CurrentPage < pagingVm.TotalPages) ? (pagingVm.CurrentPage + 1) : pagingVm.TotalPages)
                    });
                    pagingVm.Pages.Add(new PageLinkVm
                    {
                        Css        = "last",
                        PageNumber = pagingVm.TotalPages
                    });
                }
            }
            return(pagingVm);
        }
Example #2
0
        private static string FormPageLink <TResult, TSort>(ResultSetSearchVm <TResult, TSort> searchResultVm, PageDirection direction)
        {
            string empty = string.Empty;

            if (searchResultVm.PageSize == 0 || searchResultVm.PageNumber == 0)
            {
                return(empty);
            }
            if (direction == PageDirection.Next)
            {
                if ((float)searchResultVm.PageNumber < (float)searchResultVm.TotalCount / (float)searchResultVm.PageSize)
                {
                    empty = MslcUrlBuilder.PagingUrl(searchResultVm, searchResultVm.PageNumber + 1);
                }
            }
            else if (searchResultVm.PageNumber > 1)
            {
                empty = MslcUrlBuilder.PagingUrl(searchResultVm, searchResultVm.PageNumber - 1);
            }
            return(empty);
        }
Example #3
0
        private static string ReplaceWithPageNumber <TResult, TSort>(this string input, ResultSetSearchVm <TResult, TSort> data)
        {
            Regex regex;

            if (input.IsNullOrEmpty())
            {
                return(string.Empty);
            }
            bool pageNumber = data.PageNumber > 1;

            regex = (pageNumber ? SeoHelper.WithPage : SeoHelper.WithoutPage);
            Regex regex1 = (pageNumber ? SeoHelper.WithoutPage : SeoHelper.WithPage);

            foreach (Match match in regex.Matches(input))
            {
                input = input.Replace(match.Groups["pattern"].Value, match.Groups["replace"].Value);
            }
            input = regex1.Replace(input, string.Empty);
            return(input.Replace("{PAGE_NUMBER}", pageNumber, "Page {0} - ", new object[] { data.PageNumber }));
        }
Example #4
0
 private static string Replace <TResult, TSort>(this string input, ResultSetSearchVm <TResult, TSort> data)
 {
     return(input.ReplaceWithPageNumber <TResult, TSort>(data).ReplaceWithLocationData(data.Criteria));
 }