private Expression <Func <AppUser, bool> > GenerateSearchingExpression(UserSearchViewModel userSearch)
        {
            var searchHelper = new SearchHelper <AppUser>();

            if (!string.IsNullOrWhiteSpace(userSearch.Name))
            {
                searchHelper.AddAndExpression("Name", userSearch.Name, ExpressionOperation.Contains);
            }

            if (!string.IsNullOrWhiteSpace(userSearch.Email))
            {
                searchHelper.AddAndExpression("Email", userSearch.Email, ExpressionOperation.Contains);
            }

            if (userSearch.Enabled != null && !(bool)userSearch.Enabled)
            {
                searchHelper.AddAndExpression("DisabledAt", null, ExpressionOperation.NotEqualTo);
            }

            if (userSearch.Enabled != null && ((bool)userSearch.Enabled))
            {
                searchHelper.AddAndExpression("DisabledAt", null);
            }

            return(searchHelper.BuildExpression());
        }
        private Expression <Func <Reserve, bool> > GenerateExpressionForSearch(ReserveSearchViewModel reserveSearch)
        {
            var searchHelper = new SearchHelper <Reserve>();

            if (reserveSearch.MinPrice != null)
            {
                searchHelper
                .AddAndExpression("Price", reserveSearch.MinPrice, ExpressionOperation.GreaterThanOrEqualTo);
            }

            if (reserveSearch.MaxPrice != null)
            {
                searchHelper
                .AddAndExpression("Price", reserveSearch.MaxPrice, ExpressionOperation.LessThanOrEqualTo);
            }

            if (reserveSearch.MinEntry != null)
            {
                searchHelper
                .AddAndExpression("Entry", reserveSearch.MinEntry, ExpressionOperation.GreaterThanOrEqualTo);
            }

            if (reserveSearch.MaxEntry != null)
            {
                searchHelper
                .AddAndExpression("Entry", reserveSearch.MaxEntry, ExpressionOperation.LessThanOrEqualTo);
            }

            if (reserveSearch.MinDateStart != null)
            {
                searchHelper
                .AddAndExpression("DateStart", reserveSearch.MinDateStart, ExpressionOperation.GreaterThanOrEqualTo);
            }

            if (reserveSearch.MaxDateStart != null)
            {
                searchHelper
                .AddAndExpression("DateStart", reserveSearch.MaxDateStart, ExpressionOperation.LessThanOrEqualTo);
            }

            if (reserveSearch.Enabled != null && !(bool)reserveSearch.Enabled)
            {
                searchHelper
                .AddAndExpression("DisabledAt", null, ExpressionOperation.NotEqualTo);
            }

            if (reserveSearch.Enabled != null && (bool)reserveSearch.Enabled)
            {
                searchHelper
                .AddAndExpression("DisabledAt", null);
            }

            return(searchHelper.BuildExpression());
        }
        private Expression <Func <Item, bool> > GenerateExpressionForSearch(ItemSearchViewModel itemSearch)
        {
            var searchHelper = new SearchHelper <Item>();

            if (itemSearch.MinPrice != null)
            {
                searchHelper
                .AddAndExpression("Price", itemSearch.MinPrice, ExpressionOperation.GreaterThanOrEqualTo);
            }

            if (itemSearch.MaxPrice != null)
            {
                searchHelper
                .AddAndExpression("Price", itemSearch.MaxPrice, ExpressionOperation.LessThanOrEqualTo);
            }

            if (itemSearch.MinQuantity != null)
            {
                searchHelper
                .AddAndExpression("Quantity", itemSearch.MinQuantity, ExpressionOperation.GreaterThanOrEqualTo);
            }
            if (itemSearch.MaxQuantity != null)
            {
                searchHelper
                .AddAndExpression("Quantity", itemSearch.MaxQuantity, ExpressionOperation.LessThanOrEqualTo);
            }

            if (!string.IsNullOrWhiteSpace(itemSearch.Name))
            {
                searchHelper
                .AddAndExpression("Name", itemSearch.Name, ExpressionOperation.Contains);
            }

            if (!string.IsNullOrWhiteSpace(itemSearch.Description))
            {
                searchHelper
                .AddAndExpression("Description", itemSearch.Description, ExpressionOperation.Contains);
            }

            if (itemSearch.Enabled != null && !(bool)itemSearch.Enabled)
            {
                searchHelper
                .AddAndExpression("DisabledAt", null, ExpressionOperation.NotEqualTo);
            }

            if (itemSearch.Enabled != null && (bool)itemSearch.Enabled)
            {
                searchHelper
                .AddAndExpression("DisabledAt", null);
            }

            return(searchHelper.BuildExpression());
        }