/// <summary> /// Статический фабричный метод для создания экземпляра PaginationMetadata /// </summary> /// <returns>PaginationMetadata</returns> public static PaginationMetadata Create(int page, int pageSize, long totalItem, [CanBeNull] string filter = null, [CanBeNull] string filterBy = null, [CanBeNull] string orderBy = null, [CanBeNull] SortDirection?sort = null) { return(new PaginationMetadata(page, pageSize, totalItem, filter, filterBy, orderBy, sort)); }
public ActionResult ProductFacets( [Bind(Prefix = Constants.QueryString.Paging)] int?pageNumber, [Bind(Prefix = Constants.QueryString.PageSize)] int?pageSize, [Bind(Prefix = Constants.QueryString.Facets)] string facetValues, [Bind(Prefix = Constants.QueryString.Sort)] string sortField, [Bind(Prefix = Constants.QueryString.SortDirection)] SortDirection?sortDirection) { if (CatalogManager.CatalogContext == null) { return(this.InfoMessage(InfoMessage.Error("This rendering cannot be shown without a valid catalog context."))); } var currentCategory = GetCurrentCategory(); if (currentCategory == null) { return(this.InfoMessage(InfoMessage.Error(AlertTexts.InvalidDataSourceTemplateFriendlyMessage))); } var searchOptions = GetCategorySearchOptions(currentCategory, pageNumber, facetValues, pageSize, sortField, sortDirection); var viewModel = GetProductFacetsViewModel(searchOptions, currentCategory, RenderingContext.Current.Rendering); return(View(viewModel)); }
public static MvcHtmlString SortLink(this HtmlHelper html, string linkText, string sortExpression) { var controller = html.ViewContext.RouteData.Values["controller"].ToString(); var action = html.ViewContext.RouteData.Values["action"].ToString(); var routeValues = new RouteValueDictionary(); SortDirection?sort = null; var sortDirectionStr = html.ViewContext.HttpContext.Request["SortDirection"]; if (!string.IsNullOrEmpty(sortDirectionStr) && html.ViewContext.HttpContext.Request["SortExpression"] == sortExpression) { if (Enum.TryParse(sortDirectionStr, out SortDirection s)) { sort = s; } } routeValues["SortExpression"] = sortExpression; routeValues["SortDirection"] = sort.HasValue && sort.Value == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending; return(html.Partial("SortLink", new SortLinkModel { ActionName = action, ControllerName = controller, SortDirection = sort, RouteValues = routeValues, LinkText = linkText })); }
/// <summary> /// Gets list of account activities from Alpaca REST API endpoint by specific activity. /// </summary> /// <param name="activityType">The activity type you want to view entries for.</param> /// <param name="date">The date for which you want to see activities.</param> /// <param name="until">The response will contain only activities submitted before this date. (Cannot be used with date.)</param> /// <param name="after">The response will contain only activities submitted after this date. (Cannot be used with date.)</param> /// <param name="direction">The response will be sorted by time in this direction. (Default behavior is descending.)</param> /// <param name="pageSize">The maximum number of entries to return in the response.</param> /// <param name="pageToken">The ID of the end of your current page of results.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>Read-only list of asset information objects.</returns> public Task <IReadOnlyList <IAccountActivity> > ListAccountActivitiesAsync( AccountActivityType activityType, DateTime?date = null, DateTime?until = null, DateTime?after = null, SortDirection?direction = null, Int64?pageSize = null, String?pageToken = null, CancellationToken cancellationToken = default) { if (date.HasValue && (until.HasValue || after.HasValue)) { throw new ArgumentException("You unable to specify 'date' and 'until'/'after' arguments in same call."); } var builder = new UriBuilder(_httpClient.BaseAddress) { Path = _httpClient.BaseAddress.AbsolutePath + $"account/activities/{activityType.ToEnumString()}", Query = new QueryBuilder() .AddParameter("date", date, "yyyy-MM-dd") .AddParameter("until", until, "O") .AddParameter("after", after, "O") .AddParameter("direction", direction) .AddParameter("pageSize", pageSize) .AddParameter("pageToken", pageToken) }; return(_httpClient.GetObjectsListAsync <IAccountActivity, JsonAccountActivity>( _alpacaRestApiThrottler, builder, cancellationToken)); }
public MemberItemOrder Clone(MemberInfo NewMember = null, SortDirection?NewDirection = null, int?NewPrecedence = null) => new MemberItemOrder ( NewMember ?? this.Member, NewDirection ?? this.Direction, NewPrecedence ?? this.Precedence );
/// <summary> /// Performs an in-place bubble sort in an ObservableCollection. /// </summary> /// <typeparam name="T">Type of the collection.</typeparam> /// <param name="collection">Collection to sort.</param> /// <param name="sortDirection">Is it an ascending sort or a descending sort?</param> public static void BubbleSort <T>(this ObservableCollection <T> collection, SortDirection?sortDirection) where T : IComparable <T> { if (sortDirection == null) { sortDirection = SortDirection.Ascending; } for (int i = (collection.Count - 1); i >= 0; i--) { for (int j = 1; j <= i; j++) { if (sortDirection != SortDirection.Ascending) { if (collection[j - 1].CompareTo(collection[j]) < 0) { collection.Move(j - 1, j); } } else { // No error is raised if the sort direction is not in the enum: an ascending sort is made. if (collection[j - 1].CompareTo(collection[j]) > 0) { collection.Move(j - 1, j); } } } } }
public async Task <IEnumerable <Transaction> > GetTransactionsAsync(string bankId, string accountId, string viewId, SortDirection?sortDirection = null, int?limit = null, int?offset = null, DateTime?fromDate = null, DateTime?toDate = null) { try { var queryParamValues = new Dictionary <string, object> { ["sort_direction"] = sortDirection.ConvertNullableToString(), ["limit"] = limit, ["offset"] = offset, ["from_date"] = fromDate, ["to_date"] = toDate }; return((await(await GetTransactionUrlAsync(bankId, accountId, viewId)) .AppendPathSegment("/transactions") .SetQueryParams(queryParamValues) .GetJsonAsync <TransactionList>() .ConfigureAwait(false)) .GetEnumerableResults()); } catch (FlurlHttpException ex) { var errorResponse = await ex.GetResponseJsonAsync <ErrorResponse>(); throw new FlurlHttpException(ex.Call, errorResponse.Error, ex); } }
internal static IQueryString GetQueryString( int?skip = null, int?limit = null, bool?withCount = null, string orderBy = null, SortDirection?sortDirection = null) { var queryString = QueryString.Empty; if (skip != null) { queryString.Add("skip", skip.Value); } if (limit != null) { queryString.Add("limit", limit.Value); } if (withCount != null) { queryString.Add("with_count", withCount.Value.ToString().ToLower()); } if (!string.IsNullOrEmpty(orderBy)) { var sortQueryParam = orderBy; if (sortDirection == SortDirection.Descending) { sortQueryParam += "%20desc"; } queryString.Add("sort", sortQueryParam); } return(queryString); }
protected AbstractResourceListRequest(int?offset = null, int?limit = null, SortDirection?sortDir = null, TSortFieldEnumType?sortBy = null) { Offset = offset; Limit = limit; SortDir = sortDir; SortBy = sortBy; }
public async Task<IResponseResult<IPaginationCollection<T>>> GetAsync( TokenBase token, int? skip = null, int? limit = null, bool? withCount = null, string orderBy = null, SortDirection? sortDirection = null, string searchKeyword = null) { if (string.IsNullOrEmpty(searchKeyword) || string.IsNullOrEmpty(searchKeyword.Trim())) { return await this.ExecuteRequestAsync<PaginationCollection<T>>( HttpMethod.Get, $"{this.BaseUrl}/memberships/{this.MembershipId}/{this.Slug}", QueryStringHelper.GetQueryString(skip, limit, withCount, orderBy, sortDirection), HeaderCollection.Add("Authorization", token.ToString())); } else { return await this.ExecuteRequestAsync<PaginationCollection<T>>( HttpMethod.Get, $"{this.BaseUrl}/memberships/{this.MembershipId}/{this.Slug}/search", QueryStringHelper.GetQueryString(skip, limit, withCount, orderBy, sortDirection).Add("keyword", searchKeyword), HeaderCollection.Add("Authorization", token.ToString())); } }
AudibleQueryBuilder IAudibleQueryBuilder.WithSearchRankSelect( AudibleQueryField searchRankSelectField, SortDirection searchRankSelectDirection) { if (_searchRankSelectField != null) { throw new InvalidOperationException( $"The searchRankSelectField cannot be set to {searchRankSelectField.ToString().ToLower().SQuote()} " + $"because the instance of {nameof(AudibleQueryBuilder).SQuote()} already has the " + $"searchRankSelectField {_searchRankSelectField.ToString().ToLower().SQuote()}."); } _searchRankSelectField = searchRankSelectField; if (_searchRankSelectDirection != null) { throw new InvalidOperationException( $"The searchRankSelectDirection cannot be set to " + $"{searchRankSelectDirection.ToString().ToLower().Quote()} because the instance of " + $"{nameof(AudibleQueryBuilder).SQuote()} already has the searchRankSelectDirection " + $"{_searchRankSelectDirection.ToString().ToLower().SQuote()}."); } _searchRankSelectDirection = searchRankSelectDirection; return(this); }
public async Task SearchAnimeAsync_EmptyQueryWithConfigWithInvalidEnums_ShouldThrowValidationException( AiringStatus?airingStatus, AnimeAgeRating?rating, AnimeType?mangaType, AnimeSearchOrderBy?orderBy, SortDirection?sortDirection, AnimeGenreSearch?genreSearch ) { // Given var searchConfig = new AnimeSearchConfig() { Status = airingStatus.GetValueOrDefault(), Rating = rating.GetValueOrDefault(), Type = mangaType.GetValueOrDefault(), OrderBy = orderBy.GetValueOrDefault(), SortDirection = sortDirection.GetValueOrDefault(), Genres = genreSearch.HasValue ? new[] { genreSearch.Value } : Array.Empty <AnimeGenreSearch>() }; // When var func = _jikan.Awaiting(x => x.SearchAnimeAsync(searchConfig)); // Then await func.Should().ThrowExactlyAsync <JikanValidationException>(); }
public IHttpActionResult GetProductList( [FromUri(Name = "q")] string searchKeyword = null, [FromUri(Name = "pg")] int?page = null, [FromUri(Name = "f")] string facetValues = null, [FromUri(Name = "s")] string sortField = null, [FromUri(Name = "ps")] int?pageSize = null, [FromUri(Name = "sd")] SortDirection?sortDirection = null, [FromUri(Name = "cci")] string currentCatalogItemId = null, [FromUri(Name = "ci")] string currentItemId = null) { var facetValuesCollection = !string.IsNullOrEmpty(facetValues) ? HttpUtility.ParseQueryString(facetValues) : new NameValueCollection(); var model = this.productListRepository.GetProductList( this.visitorContext, currentItemId, currentCatalogItemId, searchKeyword, page, facetValuesCollection, sortField, pageSize, sortDirection); return(this.JsonOk(model)); }
ArchiveQueryBuilder IArchiveQueryBuilder.WithSort( ArchiveQueryField sortField, SortDirection sortDirection) { if (_sortField != null) { throw new InvalidOperationException( $"The sortField cannot be set to {sortField.ToString().ToLower().Quote()} because the " + $"instance of {nameof(ArchiveQueryBuilder).SQuote()} already has the sortField " + $"{_sortField.ToString().ToLower().SQuote()}."); } _sortField = sortField; if (_sortDirection != null) { throw new InvalidOperationException( $"The sortDirection cannot be set to {sortDirection.ToString().ToLower().Quote()} because the " + $"instance of {nameof(ArchiveQueryBuilder).SQuote()} already has the sortDirection " + $"{_sortDirection.ToString().ToLower().SQuote()}."); } _sortDirection = sortDirection; return(this); }
public IQueryable <T> Apply(IQueryable <T> query, SortDirection?direction = null) { var dir = direction.HasValue ? direction.Value : DefaultDirection; var method = dir == SortDirection.Ascending ? ascendingMethod : descendingMethod; return((IQueryable <T>)method.Invoke(null, new object[] { query, lambda })); }
{ //класс разметки public static MvcHtmlString SortLink(this HtmlHelper html, string linkText, string sortExpression, string action, string controller, RouteValueDictionary routeValues) { routeValues = routeValues ?? new RouteValueDictionary(); SortDirection?sort = null; var sortDirectionStr = html.ViewContext.HttpContext.Request["SortDirection"]; //ViewContext - позволяет забрать данные из View if (!string.IsNullOrEmpty(sortDirectionStr) && html.ViewContext.HttpContext.Request["SortExpression"] == sortExpression) { SortDirection s; if (Enum.TryParse(sortDirectionStr, out s)) { sort = s; } } routeValues["SortExpression"] = sortExpression; routeValues["SortDirection"] = sort.HasValue && sort.Value == SortDirection.Asc ? SortDirection.Desc : SortDirection.Asc; return(html.Partial("SortLink", new SortLinkModel { Action = action, Controller = controller, SortDirection = sort, RouteValues = routeValues, LinkText = linkText })); }
public ProjectsQuery(int offset, int count, bool?isPrivate, bool onlyScored, string searchString, Stage?stage, string countryCode, Category?category, int?minimumScore, int?maximumScore, ProjectsOrderBy?orderBy, SortDirection?direction, IReadOnlyCollection <ScoringStatus> scoringStatuses, IReadOnlyCollection <long> projectIds) { Offset = offset; Count = count; SearchString = searchString; Stage = stage; CountryCode = countryCode; Category = category; MinimumScore = minimumScore; MaximumScore = maximumScore; OrderBy = orderBy; Direction = direction; OnlyScored = onlyScored; IsPrivate = isPrivate; ScoringStatuses = scoringStatuses; ProjectIds = projectIds; }
/// <summary> /// Gets list of account activities from Alpaca REST API endpoint. /// </summary> /// <param name="activityTypes">The activity type you want to view entries for.</param> /// <param name="date">The date for which you want to see activities.</param> /// <param name="until">The response will contain only activities submitted before this date. (Cannot be used with date.)</param> /// <param name="after">The response will contain only activities submitted after this date. (Cannot be used with date.)</param> /// <param name="direction">The response will be sorted by time in this direction. (Default behavior is descending.)</param> /// <param name="pageSize">The maximum number of entries to return in the response.</param> /// <param name="pageToken">The ID of the end of your current page of results.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>Read-only list of asset information objects.</returns> public Task <IEnumerable <IAsset> > ListAccountActivitiesAsync( IEnumerable <AccountActivityType> activityTypes = null, DateTime?date = null, DateTime?until = null, DateTime?after = null, SortDirection?direction = null, Int64?pageSize = null, String pageToken = null, CancellationToken cancellationToken = default) { if (date.HasValue && (until.HasValue || after.HasValue)) { throw new ArgumentException("You unable to specify 'date' and 'until'/'after' arguments in same call."); } var builder = new UriBuilder(_alpacaHttpClient.BaseAddress) { Path = _alpacaHttpClient.BaseAddress.AbsolutePath + "account/activities", Query = new QueryBuilder() .AddParameter("activity_types", string.Join(",", activityTypes)) .AddParameter("date", date) .AddParameter("until", until) .AddParameter("after", after) .AddParameter("direction", direction) .AddParameter("pageSize", pageSize) .AddParameter("pageToken", pageToken) }; return(getObjectsListAsync <IAsset, JsonAsset>( _alpacaHttpClient, _alpacaRestApiThrottler, builder, cancellationToken)); }
IGridColumnConfiguration <TModel> IGridColumnConfiguration <TModel> .SortColumn <TProperty>(Expression <Func <TModel, TProperty> > property, SortDirection initialDirection) { _sortProperty = property; _sortDirection = initialDirection; return(this); }
protected abstract Task <IPaginationCollection <dynamic> > GetDataAsync( string query, int?skip, int?limit, bool?withCount, string sortField, SortDirection?sortDirection, IDictionary <string, bool> selectFields);
public JsonResult SortOrderApplied(string sortField, SortDirection?sortDirection) { if (!string.IsNullOrWhiteSpace(sortField) && StorefrontContext.Current != null) { CatalogManager.SortOrderApplied(sortField, sortDirection); } return(new BaseApiModel()); }
public PaginablePagination(IPaginable <T> query, int pageNumber, int pageSize, string sortExpression, SortDirection?sortDirection) : base(pageNumber, pageSize, sortExpression, sortDirection) { Query = query; }
public IResponseResult <IPaginationCollection <RevokedToken> > GetRevokedTokens( string userId, TokenBase token, int?skip = null, int?limit = null, bool?withCount = null, string orderBy = null, SortDirection?sortDirection = null) => this.GetRevokedTokensAsync(userId, token, skip, limit, withCount, orderBy, sortDirection).ConfigureAwait(false).GetAwaiter().GetResult();
public ListModel(int?page, SortFieldEnumType?sort, SortDirection?sortDirection) { InitializeSortFunctions(); this.Page = (page.HasValue ? page.Value : 1); this.PageSize = ConfigUtil.Instance.PageSize; this.Sort = (sort.HasValue ? sort.Value : default(SortFieldEnumType)); this.SortDirection = (sortDirection.HasValue ? sortDirection.Value : SortDirection.Ascending); }
public virtual IQueryable <TEntity> GetAll <TEntity>( string orderBy = null, string includeProperties = null, int?skip = null, int?take = null, SortDirection?sortDirection = null) where TEntity : Entity, IEntity { return(GetQueryable <TEntity>(null, includeProperties)); }
public IResponseResult<IPaginationCollection<T>> Get( TokenBase token, int? skip = null, int? limit = null, bool? withCount = null, string orderBy = null, SortDirection? sortDirection = null, string searchKeyword = null) => this.GetAsync(token, skip, limit, withCount, orderBy, sortDirection, searchKeyword) .ConfigureAwait(false).GetAwaiter().GetResult();
public Thead(ISort sort, string text, string column, Func<string, SortDirection?, string> urlBuilder, string @class) { this.sort = sort; this.text = text; this.column = column; this.urlBuilder = urlBuilder; direction = sort.GetSortDataFor(column); this.@class = @class; }
public SortOption(string name, object property, SortDirection?sortDirection = null) { if (name == null) { throw new ArgumentNullException(nameof(name)); } this.Name = name; this.Property = property; this.SortDirection = sortDirection; }
public IEnumerable <T> ToEnumerable(int skip, int take, string sortColumn, SortDirection?sortDirection) { Order[] order = this.order; if (sortColumn != null && sortDirection != null) { order = new Order[] { TranslateSortOrder(sortColumn, sortDirection.Value) }; } return(DoListPage(skip, take, order)); }
public virtual IQueryable <TEntity> Get <TEntity>( Expression <Func <TEntity, bool> > filter = null, string orderBy = null, string includeProperties = null, int?skip = null, int?take = null, SortDirection?sortDirection = null) where TEntity : Entity, IEntity { return(GetQueryable <TEntity>(filter, includeProperties)); }
public async Task <IPaginationCollection <dynamic> > QueryAsync( string query, int?skip = null, int?limit = null, bool?withCount = null, string sortField = null, SortDirection?sortDirection = null, IDictionary <string, bool> selectFields = null) { return(await this.repository.QueryAsync(query, skip, limit, withCount, sortField, sortDirection, selectFields)); }
public IndexColumnDefinition(string name, SortDirection? sortDirection) : this(name) { this.sortDirection = sortDirection; }