/// <summary> /// Prepares the paging parameters. /// </summary> /// <param name="parameters">The parameters.</param> /// <returns></returns> protected virtual PagingParameters PreparePagingParameters(PagingSortingBaseModel parameters) { return(new PagingParameters { CurrentPage = parameters.CurrentPage > 1 ? parameters.CurrentPage : GetDefaultCurrentPage(), ItemsPerPage = parameters.PageSize > 0 ? parameters.PageSize : GetDefaultItemsPerPage() }); }
/// <summary> /// Prepares the sort parameters. /// </summary> /// <param name="parameters">The parameters.</param> /// <param name="allowedSortBy">Fields that are allowed for sorting in overview.</param> /// <returns></returns> protected virtual SortingParameters PrepareSortParameters(PagingSortingBaseModel parameters, ICollection <string> allowedSortBy) { var isValidParameter = parameters.SortBy != null && allowedSortBy.Contains(parameters.SortBy.ToLower()); if (isValidParameter) { return(new SortingParameters { SortField = parameters.SortBy, SortReverse = parameters.Order == DescendingSortOrder }); } var defaultSortingParameters = GetDefaultSortingParameters(); if (defaultSortingParameters != null) { return(defaultSortingParameters); } return(SortingParameters.CreateNoSortingNeededParams()); }