public static IQueryable <Subdivision> SortSubdivisions(this IQueryable <Subdivision> querySubdivision, SortPage condition) { return(condition switch { SortPage.NameIncrease => querySubdivision.OrderBy(t => t.Name), SortPage.NameDecrease => querySubdivision.OrderByDescending(t => t.Name), SortPage.TypeIncrease => querySubdivision.OrderBy(t => t.Type), SortPage.TypeDecrease => querySubdivision.OrderByDescending(t => t.Type), SortPage.AreaIncrease => querySubdivision.OrderBy(t => t.Area), SortPage.AreaDecrease => querySubdivision.OrderByDescending(t => t.Area), SortPage.CapacityIncrease => querySubdivision.OrderBy(t => t.Capacity), SortPage.CapacityDecrease => querySubdivision.OrderByDescending(t => t.Capacity), _ => querySubdivision });
public async Task <Page <Subdivision> > GetPage( [FromQuery] string keyword, [FromQuery] int?filterSubdivisionType, [FromQuery] int?filterSubdivisionArea, [FromQuery] SortPage sortPage = SortPage.NameIncrease, [FromQuery] int pageSize = PaginatorConstants.DefaultPageSize, [FromQuery] int page = PaginatorConstants.DefaultPageNumber) { var param = new SubdivisionPageDto { Keyword = keyword, FilterSubdivisionType = filterSubdivisionType, FilterSubdivisionArea = filterSubdivisionArea, SortPage = sortPage, PageSize = pageSize, Page = page }; return(await _subdivisionRepository.GetPage(param)); }