public Task BindModelAsync(ModelBindingContext bindingContext) { var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName); var old = bindingContext.Model as ListPagination; var result = old; if (value.FirstValue.HasValue()) { result = new ListPagination(old?.Container, value.FirstValue) { Prefix = old.Prefix, }; if (old != null) { result.UseAjaxPost = old.UseAjaxPost; result.UseAjaxGet = old.UseAjaxGet; } } bindingContext.Result = ModelBindingResult.Success(result); return(Task.CompletedTask); }
public Task BindModelAsync(ModelBindingContext bindingContext) { var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName); var prefix = bindingContext.ModelName.OrEmpty().Unless("p"); if (prefix.EndsWith(".p")) { prefix = prefix.Split('.').ExceptLast().ToString("."); } var old = bindingContext.Model as ListPagination; var result = old; if (value.FirstValue.HasValue()) { result = new ListPagination(old?.Container, value.FirstValue); if (old != null) { result.UseAjaxPost = old.UseAjaxPost; result.UseAjaxGet = old.UseAjaxGet; } } bindingContext.Result = ModelBindingResult.Success(result); return(Task.CompletedTask); }
public PaginationRenderer(IHtmlHelper html, ListPagination paging, int visiblePages, object htmlAttributes, string prefix) { Html = html; Paging = paging; VisiblePages = visiblePages; HtmlAttributes = htmlAttributes; Prefix = prefix; }
public static IEnumerable <T> TakePage <T>(this IEnumerable <T> list, ListPagination paging) { if (paging.PageSize == null) { return(list); } var pageSize = paging.PageSize.Value; var currentPage = paging.CurrentPage.LimitMin(1); var skip = pageSize * (currentPage - 1); if (currentPage > 1 && skip > list.Count()) { skip = 0; } return(list.Take(skip, pageSize)); }
public static IEnumerable <T> TakePage <T>(this IEnumerable <T> list, ListPagination paging) => list.TakePage(paging.PageSize, paging.CurrentPage);
public static T Page <T>(this T query, ListPagination paging) where T : IDatabaseQuery { query.Page(paging.CurrentPage, paging.PageSize ?? 100000); return(query); }
public static HtmlString Pagination(this IHtmlHelper html, ListPagination paging, int visiblePages, object htmlAttributes = null, string prefix = null) => new PaginationRenderer(html, paging, visiblePages, htmlAttributes, prefix).Render();
public static HtmlString Pagination(this IHtmlHelper html, ListPagination paging, object htmlAttributes = null, string prefix = null) => Pagination(html, paging, DEFAULT_VISIBLE_PAGES, htmlAttributes, prefix);
public static T Page <T>(this T query, ListPagination paging) where T : IDatabaseQuery { query.Page((paging.CurrentPage - 1) * paging.PageSize ?? DEFATLT_PAGE_SIZE, paging.PageSize ?? DEFATLT_PAGE_SIZE); return(query); }