コード例 #1
0
        public PageListRequest <TEntity> OrderBy(OrderDir direction, params string[] orders)
        {
            this._orderDirection = direction;
            this._orders         = orders;

            return(this);
        }
コード例 #2
0
        /// <summary>
        /// List SKUs of specific category.
        /// </summary>
        /// <param name="categoryId">Unique identifier of the Category</param>
        /// <param name="orderBy">Order by price, popularity or rating</param>
        /// <param name="orderDir">Order by ascending or descending</param>
        /// <param name="searchKeyword">The keyword to search by</param>
        /// <param name="metaFilters">The meta filters.</param>
        /// <param name="manufacturerIds">The ids of the manufacturers of the SKUs</param>
        /// <param name="filterIds">The ids of the filters to be applied on the SKUs</param>
        /// <param name="sparseFields">Sparse fields are a way for clients to request specific json fields from the server response.</param>
        /// <returns>Task&lt;SKUs&gt;.</returns>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="categoryId" /> is less than or equal to 0.</exception>
        /// <see href="https://developer.skroutz.gr/api/v3/sku/#list-skus-of-specific-category"></see>
        /// <remarks>The default <c>order_by value</c> may differ across categories but in most cases it's <c>pricevat</c>.</remarks>
        public Task <SKUs> ListSKUsOfSpecificCategory(int categoryId, OrderByPrcPopRating orderBy = OrderByPrcPopRating.pricevat, OrderDir orderDir = OrderDir.asc, string searchKeyword = null, MetaFilters?metaFilters = null, IList <int> manufacturerIds = null, IList <int> filterIds = null, params Expression <Func <SKU, object> >[] sparseFields)
        {
            if (categoryId <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(categoryId));
            }
            //TODO: perform check
            //if (metaFilters.HasValue && metaFilters == MetaFilters.AppliedFilters)
            //{
            //    if(manufacturerIds == null && filterIds == null) throw new ArgumentOutOfRangeException(nameof(metaFilters));
            //}

            _skroutzRequest.SBuilder.Clear();
            _skroutzRequest.SBuilder.Append($"categories/{categoryId}/skus?");
            _skroutzRequest.SBuilder.Append($"order_by={orderBy}");
            _skroutzRequest.SBuilder.Append($"&order_dir={orderDir}");

            if (!string.IsNullOrEmpty(searchKeyword))
            {
                _skroutzRequest.SBuilder.Append($"&q={searchKeyword}");
            }

            if (manufacturerIds != null)
            {
                _skroutzRequest.SBuilder.Append($"&manufacturer_ids[]={string.Join("&manufacturer_ids[]=", manufacturerIds.Select(s => s.ToString()))}");
            }

            if (filterIds != null)
            {
                _skroutzRequest.SBuilder.Append($"&filter_ids[]={string.Join("&filter_ids[]=", filterIds.Select(s => s.ToString()))}");
            }

            if (sparseFields.Length > 0)
            {
                _skroutzRequest.SBuilder.Append($"&fields[root]={NameReader.GetMemberNames(sparseFields)}");
            }

            _skroutzRequest.Method = HttpMethod.GET;

            return(GetWebResultAsync(_skroutzRequest).ContinueWith((t) =>
                                                                   JsonConvert.DeserializeObject <SKUs>(t.Result.ToString())));
        }
コード例 #3
0
ファイル: Sort.cs プロジェクト: KBrizzle/DankWire
 public void sortBy(Column col, OrderDir dir)
 {
     int[] list = new int[Rows];
     if (col == Column.Relevance) list = _Order;
     if (col == Column.Length) list = TimeToInt(_Length);
     if (col == Column.Views) list = ArrayToInt(_Views);
     foreach (int l in list) Temp.Add(l);
     while (OCount.Count > 0)
     {
         int next = 0;
         if (dir == OrderDir.Asc) next = Temp.Max();
         if (dir == OrderDir.Desc) next = Temp.Min();
         for (int i = 0; i < Rows; i++)
         {
             if (Temp[i] == next)
             {
                 NCount.Add(OCount[i]);
                 OCount.RemoveAt(i);
                 Temp.RemoveAt(i);
                 break;
             }
         }
     }
     LV.Items.Clear();
     for (int i = 0; i < Rows; i++)
     {
         ListViewItem item = new ListViewItem(_Title[NCount[i]]);
         item.SubItems.Add(_Views[NCount[i]]);
         item.SubItems.Add(_Length[NCount[i]]);
         LV.Items.Add(item);
         IDs.Add(_IDs[NCount[i]]);
         Order.Add(_Order[NCount[i]]);
     }
 }
コード例 #4
0
 public static SelectQuery OrderBy(this SelectQuery query, Table table, string field, OrderDir direction = OrderDir.Asc, Aggregate aggregate = Aggregate.None)
 {
     query.OrderBy(table.Alias, field, direction, aggregate);
     return(query);
 }
コード例 #5
0
        public static SelectQuery OrderBy(this SelectQuery query, string tableAlias, string field, OrderDir direction = OrderDir.Asc, Aggregate aggregate = Aggregate.None)
        {
            var orderBy = new OrderByColumn(tableAlias, field, direction, aggregate);

            query.OrderByColumns.Add(orderBy);
            return(query);
        }
コード例 #6
0
ファイル: DigisellerClient.cs プロジェクト: msdoc11/Digishop
        /// <summary>
        /// Get products by seller id
        /// </summary>
        /// <param name="sellerId">Seller Id</param>
        /// <param name="pageNumber">Page number (pagination)</param>
        /// <param name="rowsCount">Count of products per page</param>
        /// <param name="currency">Currency for prices</param>
        /// <param name="orderColumn">Sorting column</param>
        /// <param name="orderDir">Sorting by</param>
        /// <param name="language">Language information</param>
        /// <returns></returns>
        public async Task <Interfaces.SellerProducts.ISellerProducts> GetSellerProducts(int sellerId, int pageNumber = 1, int rowsCount = 20, Currency currency = Currency.RUR,
                                                                                        OrderColumn orderColumn      = OrderColumn.Name, OrderDir orderDir = OrderDir.Asc,
                                                                                        Language language            = Language.Russian)
        {
            var request = new DigisellerSellerProductsRequest(sellerId, orderColumn.ToString().ToLower(), orderDir.ToString().ToLower(), rowsCount, pageNumber,
                                                              currency.ToString(), _languages[language]);

            var response =
                await GetDigisellerDataAsync(request, new XmlSerializer <DigisellerSellerProductsRequest, DigisellerSellerProductsResponseXml>(),
                                             UrlGetSellerGoods);

            return(response != null ? new SellerProducts(response) : null);
        }
コード例 #7
0
ファイル: DigisellerClient.cs プロジェクト: msdoc11/Digishop
 /// <summary>
 /// Get products by current seller
 /// </summary>
 /// <param name="pageNumber">Page number (pagination)</param>
 /// <param name="rowsCount">Count of products per page</param>
 /// <param name="currency">Currency for prices</param>
 /// <param name="orderColumn">Sorting column</param>
 /// <param name="orderDir">Sorting by</param>
 /// <param name="language">Language information</param>
 /// <returns></returns>
 public async Task <Interfaces.SellerProducts.ISellerProducts> GetSellerProducts(int pageNumber          = 1, int rowsCount = 20, Currency currency = Currency.RUR,
                                                                                 OrderColumn orderColumn = OrderColumn.Name, OrderDir orderDir = OrderDir.Asc,
                                                                                 Language language       = Language.Russian)
 {
     return(await GetSellerProducts(SellerId, pageNumber, rowsCount, currency, orderColumn, orderDir, language));
 }
コード例 #8
0
 public OrderByColumn(string tableAlias, string fieldName, OrderDir direction, Aggregate aggregate = Aggregate.None)
     : base(tableAlias, fieldName)
 {
     Direction = direction;
     Aggregate = aggregate;
 }
コード例 #9
0
ファイル: OrderDir.cs プロジェクト: kwaclaw/SqlModeller
 public static string ToSqlString(this OrderDir value)
 {
     return(value.ToString().ToUpper());
 }