示例#1
0
        public List <Product> FindByCategoryId(string categoryBvin, CategorySortOrder sort,
                                               bool showUnavailable,
                                               int pageNumber, int pageSize, ref int totalResults)
        {
            var profiler = MiniProfiler.Current;

            ProductSearchCriteria criteria = new ProductSearchCriteria();

            criteria.CategorySort            = sort;
            criteria.CategoryId              = categoryBvin;
            criteria.DisplayInactiveProducts = showUnavailable;
            if (showUnavailable)
            {
                criteria.InventoryStatus = ProductInventoryStatus.NotSet;
            }
            else
            {
                criteria.InventoryStatus = ProductInventoryStatus.Available;
            }
            int            totalFromSearch = 0;
            List <Product> results         = FindByCriteria(criteria, pageNumber, pageSize, ref totalFromSearch);

            totalResults = totalFromSearch;
            return(results);
        }
        private List <SelectListItem> LoadSortSelectList(Category cat, CategorySortOrder sortOrder,
                                                         bool isDrillDown = false)
        {
            var categorySettings = new CategoryModuleSettings(ModuleContext.ModuleId);
            var items            = new List <SelectListItem>();
            var sortOrders       = categorySettings.SortOrderOptions;

            sortOrders.Insert(0, CategorySortOrder.ManualOrder);

            foreach (var order in sortOrders)
            {
                var url = !isDrillDown
                    ? BuildUrlForCategory(cat, null, new { sort = (int)order })
                    : ((int)order).ToString();

                var text = Localization.GetString(string.Format("CategorySortOrder{0}", order));
                items.Add(new SelectListItem {
                    Selected = sortOrder == order, Text = text, Value = url
                });
            }

            return(items);
        }
示例#3
0
 /// <summary>
 /// Sorts the categories of a sequence according to a key.
 /// </summary>
 public static IQueryable <LoggingCategory> OrderBy(this IQueryable <LoggingCategory> query, CategorySortOrder orderBy)
 {
     if (orderBy == CategorySortOrder.Name)
     {
         return(query.OrderBy(p => p.Name));
     }
     if (orderBy == CategorySortOrder.Recent)
     {
         return(query.OrderByDescending(p => p.ModifiedDate));
     }
     return(query.OrderBy(p => p.Id));
 }
 /// <summary>
 /// Finds a collection of categories with the given values.
 /// </summary>
 /// <param name="user">The user for the item to be found.</param>
 /// <param name="project">The project for the item to be found.</param>
 /// <param name="orderBy">The order in which items are returned in a result set.</param>
 /// <param name="fields">The related fields to include in the query results.</param>
 /// <param name="cancellationToken">A token to observe while waiting for the task to complete.</param>
 /// <returns>
 /// A task that represents the asynchronous operation.
 /// </returns>
 public virtual Task <ListResult <CategoryItem> > FindAllAsync(AccountItem user, ProjectItem project, CategorySortOrder orderBy, CategoryField fields, CancellationToken cancellationToken)
 {
     cancellationToken.ThrowIfCancellationRequested();
     ThrowIfDisposed();
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     return(Categories
            .Where(user.Id, project?.Id)
            .OrderBy(orderBy)
            .Select(fields)
            .ToListResultAsync(cancellationToken));
 }
示例#5
0
 public static IEnumerable <OperationCategory> Order(this IEnumerable <OperationCategory> categories, CategorySortOrder order)
 {
     if (order == CategorySortOrder.Name)
     {
         return(categories.OrderBy(x => x.Name));
     }
     else
     {
         return(categories.OrderByDescending(x => x.Usage));
     }
 }
示例#6
0
 /// <summary>
 /// Finds a collection of categories with the given values.
 /// </summary>
 /// <param name="user">The user for the item to be found.</param>
 /// <param name="project">The project for the item to be found.</param>
 /// <param name="orderBy">The order in which items are returned in a result set.</param>
 /// <param name="fields">The related fields to include in the query results.</param>
 /// <param name="cancellationToken">A token to observe while waiting for the task to complete.</param>
 /// <returns>
 /// A task that represents the asynchronous operation.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">user</exception>
 public virtual Task <ListResult <CategoryItem> > FindAllAsync(AccountItem user, ProjectItem project, CategorySortOrder orderBy, CategoryField fields, CancellationToken cancellationToken)
 {
     ThrowIfDisposed();
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     return(Store.FindAllAsync(user, project, orderBy, fields, cancellationToken));
 }