public IActionResult List(PageInfoDto pageInfoDto) { var result = _orderService.GetOrderList(pageInfoDto.Current - 1, pageInfoDto.RowCount); return(Ok(new { current = pageInfoDto.Current, rowCount = pageInfoDto.RowCount, total = result.TotalCount, rows = result.Items, })); }
public PagedCharacters(int currentPage, PageInfoDto pageInfo, IEnumerable <Character> characters) { CurrentPage = currentPage; this.PageInfo = pageInfo; this.Characters = characters; }
public IActionResult GetDataTable([FromBody] PageInfoDto pageInfoDto) { pageInfoDto ??= new PageInfoDto { PageNo = 1, OnePageCount = 10, SortColumn = "Id", ClickSortColumn = "Id", SortColumnOrder = SortColumnOrder.Desc }; pageInfoDto.DataCount = _data.Length; // 前端排序整理 if (string.IsNullOrWhiteSpace(pageInfoDto.ClickSortColumn) == false) { if (pageInfoDto.SortColumn == pageInfoDto.ClickSortColumn) { if (pageInfoDto.SortColumnOrder == SortColumnOrder.Asc) { pageInfoDto.SortColumnOrder = SortColumnOrder.Desc; } else { pageInfoDto.SortColumnOrder = SortColumnOrder.Asc; } } else { pageInfoDto.SortColumn = pageInfoDto.ClickSortColumn; pageInfoDto.SortColumnOrder = SortColumnOrder.Asc; } pageInfoDto.ClickSortColumn = string.Empty; } IEnumerable <Dto> result = _data; if (pageInfoDto.SortColumnOrder == SortColumnOrder.Asc) { if (pageInfoDto.SortColumn == "Id") { result = result.OrderBy(r => r.Id); } else if (pageInfoDto.SortColumn == "Name") { result = result.OrderBy(r => r.Name); } else if (pageInfoDto.SortColumn == "Age") { result = result.OrderBy(r => r.Age); } } else { if (pageInfoDto.SortColumn == "Id") { result = result.OrderByDescending(r => r.Id); } else if (pageInfoDto.SortColumn == "Name") { result = result.OrderByDescending(r => r.Name); } else if (pageInfoDto.SortColumn == "Age") { result = result.OrderByDescending(r => r.Age); } } result = result.Skip(pageInfoDto.Skip).Take(pageInfoDto.PageCount); return(Ok(new { PageInfo = pageInfoDto, Data = result })); }