Esempio n. 1
0
        /// <summary>
        /// The GetHackerNewsItemExpressionSort.
        /// </summary>
        /// <param name="expressionBuilder">The expressionBuilder<see cref="LambdaExpressionBuilder{HackerNewsItem}"/>.</param>
        /// <param name="orderByField">The orderByField<see cref="HackerNewsFieldEnum"/>.</param>
        /// <param name="orderByFieldDesc">The orderByFieldDesc<see cref="bool"/>.</param>
        /// <returns>The <see cref="Expression{Func{HackerNewsItem, object}}"/>.</returns>
        private Expression <Func <HackerNewsItem, object> > GetHackerNewsItemExpressionSort(LambdaExpressionBuilder <HackerNewsItem> expressionBuilder, HackerNewsFieldEnum orderByField, bool orderByFieldDesc)
        {
            QuerySort querySort = new QuerySort
            {
                PropertyPath = orderByField.GetDescription(),
                Desc         = orderByFieldDesc
            };

            return(expressionBuilder.BuildQuerySortingExpression(querySort));
        }
Esempio n. 2
0
        /// <summary>
        /// The GetHackerNewsItemExpressionFilter.
        /// </summary>
        /// <param name="expressionBuilder">The expressionBuilder<see cref="LambdaExpressionBuilder{HackerNewsItem}"/>.</param>
        /// <param name="filterField">The filterField<see cref="HackerNewsFieldEnum"/>.</param>
        /// <param name="filterOperation">The filterOperation<see cref="HackerNewsFilterOperationEnum"/>.</param>
        /// <returns>The <see cref="Expression{Func{HackerNewsItem, bool}}"/>.</returns>
        private Expression <Func <HackerNewsItem, bool> > GetHackerNewsItemExpressionFilter(LambdaExpressionBuilder <HackerNewsItem> expressionBuilder, HackerNewsFieldEnum filterField, HackerNewsFilterOperationEnum filterOperation)
        {
            IList <QueryFilter> queryFilterList = new List <QueryFilter>();

            var queryFilter = new QueryFilter
            {
                PropertyPath = filterField.GetDescription(),
            };

            if (filterOperation == HackerNewsFilterOperationEnum.MoreThanFiveWords)
            {
                queryFilter.Operator      = LambdaExpressionBuilder.Enums.OperatorEnum.GreaterThan;
                queryFilter.PropertyValue = "5";
            }

            if (filterOperation == HackerNewsFilterOperationEnum.MoreThanOrEqualToFiveWords)
            {
                queryFilter.Operator      = LambdaExpressionBuilder.Enums.OperatorEnum.GreaterThanOrEqualTo;
                queryFilter.PropertyValue = "5";
            }

            if (filterOperation == HackerNewsFilterOperationEnum.LessThanFiveWords)
            {
                queryFilter.Operator      = LambdaExpressionBuilder.Enums.OperatorEnum.LessThan;
                queryFilter.PropertyValue = "5";
            }

            if (filterOperation == HackerNewsFilterOperationEnum.LessThanOrEqualToFiveWords)
            {
                queryFilter.Operator      = LambdaExpressionBuilder.Enums.OperatorEnum.LessThanOrEqualTo;
                queryFilter.PropertyValue = "5";
            }

            queryFilterList.Add(queryFilter);

            return(expressionBuilder.BuildQueryFilteringExpression(queryFilterList));
        }