Exemple #1
0
        private IEnumerable <Order> InitCollectionByQuerry(NameValueCollection queryString)
        {
            var filter           = new OrdersCollectionFilter(connectionString, providerName);
            var constraintParser = new QueryStringParser(queryString);

            return(filter.GetFilteredCollection(constraintParser));
        }
        public IEnumerable <Order> GetFilteredCollection(QueryStringParser constraints)
        {
            var resultCollection = dbContext.GetAllByCustomer(constraints.CustID);

            if (constraints.IsDateFromExist())
            {
                resultCollection = resultCollection.Where(o => o.OrderDate >= constraints.DateFrom);
            }

            if (constraints.IsDateToExist())
            {
                resultCollection = resultCollection.Where(o => o.OrderDate <= constraints.DateTo);
            }

            if (constraints.IsSkipExist())
            {
                resultCollection = resultCollection.Skip(constraints.Skip);
            }

            if (constraints.IsTakeExist())
            {
                resultCollection = resultCollection.Take(constraints.Take);
            }

            return(resultCollection);
        }