private Expression <Func <TicketActionLogEntryDbModel, bool> > ComposeFilter(TicketLogsFilter filter)
        {
            var exp = base.ComposeBaseFilter <TicketActionLogEntryDbModel>(filter);

            if (!string.IsNullOrWhiteSpace(filter.UserId))
            {
                exp = PredicateExtensions.And(exp, entry => entry.UserId.ToLower().Contains(filter.UserId.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.TicketId))
            {
                exp = PredicateExtensions.And(exp, entry => entry.TicketId.ToLower().Contains(filter.TicketId.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.TicketName))
            {
                exp = PredicateExtensions.And(exp, entry => entry.TicketName.ToLower().Contains(filter.TicketName.ToLower()));
            }

            if (filter.ActionType != TicketActionType.Unknown)
            {
                exp = PredicateExtensions.And(exp, entry => filter.ActionType.HasFlag((TicketActionType)entry.Type));
            }

            if (!string.IsNullOrWhiteSpace(filter.Description))
            {
                exp = PredicateExtensions.And(exp, entry => entry.Description.ToLower().Contains(filter.Description.ToLower()));
            }

            return(exp);
        }
        private Expression <Func <AccountLogEntryDbModel, bool> > ComposeFilter(AccountLogsFilter filter)
        {
            var exp = base.ComposeBaseFilter <AccountLogEntryDbModel>(filter);

            if (!string.IsNullOrWhiteSpace(filter.UserId))
            {
                exp = PredicateExtensions.And(exp, entry => entry.UserId.ToLower().Contains(filter.UserId.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.UserName))
            {
                exp = PredicateExtensions.And(exp, entry => entry.UserName.ToLower().Contains(filter.UserName.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.Email))
            {
                exp = PredicateExtensions.And(exp, entry => entry.Email.ToLower().Contains(filter.Email.ToLower()));
            }

            if (filter.Type != AccountActionType.Unknown)
            {
                exp = PredicateExtensions.And(exp, entry => filter.Type.HasFlag((AccountActionType)entry.Type));
            }

            return(exp);
        }
        private Expression <Func <PaymentLogEntryDbModel, bool> > ComposeFilter(PaymentLogsFilter filter)
        {
            var exp = base.ComposeBaseFilter <PaymentLogEntryDbModel>(filter);

            if (!string.IsNullOrWhiteSpace(filter.RecieverId))
            {
                exp = PredicateExtensions.And(exp, entry => entry.RecieverId.ToLower().Contains(filter.RecieverId.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.SenderId))
            {
                exp = PredicateExtensions.And(exp, entry => entry.SenderId.ToLower().Contains(filter.SenderId.ToLower()));
            }

            if (filter.MinTransfer.HasValue)
            {
                exp = PredicateExtensions.And(exp, entry => entry.Transfer >= filter.MinTransfer.Value);
            }

            if (filter.MaxTransfer.HasValue)
            {
                exp = PredicateExtensions.And(exp, entry => entry.Transfer <= filter.MaxTransfer.Value);
            }

            return(exp);
        }
Beispiel #4
0
        protected Expression <Func <TModel, bool> > ComposeBaseFilter <TModel>(BaseLogFilter filter) where TModel : BaseLogEntryDbModel
        {
            var exp = PredicateExtensions.Begin <TModel>();

            if (filter.DateFrom.HasValue)
            {
                exp = PredicateExtensions.And <TModel>(exp, error => error.EventDate >= filter.DateFrom);
            }

            if (filter.DateTo.HasValue)
            {
                exp = PredicateExtensions.And <TModel>(exp, error => error.EventDate <= filter.DateTo);
            }

            return(exp);
        }
Beispiel #5
0
        public void TestPredicateExtensions()
        {
            var predicate = PredicateExtensions.And <int>(x => x > 10, x => x > 20);

            Assert.IsTrue(predicate(21));
            Assert.IsFalse(predicate(15));
            Assert.IsFalse(predicate(5));

            predicate = PredicateExtensions.Or <int>(x => x > 10, x => x < 0);
            Assert.IsTrue(predicate(15));
            Assert.IsTrue(predicate(-15));
            Assert.IsFalse(predicate(5));

            predicate = PredicateExtensions.IsNotTrue <int>(x => x == 0);
            Assert.IsTrue(predicate(-1));
            Assert.IsFalse(predicate(0));
        }
        private Expression <Func <SearchQueryLogEntryDbModel, bool> > ComposeFilter(SearchQueryLogsFilter filter)
        {
            var exp = base.ComposeBaseFilter <SearchQueryLogEntryDbModel>(filter);

            if (!string.IsNullOrWhiteSpace(filter.UserId))
            {
                exp = PredicateExtensions.And(exp, entry => entry.UserId.ToLower().Contains(filter.UserId.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.SearchCriterium))
            {
                exp = PredicateExtensions.And(exp, entry => entry.SearchCriterium.ToLower().Contains(filter.SearchCriterium.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.FilterInfo))
            {
                exp = PredicateExtensions.And(exp, entry => entry.FilterInfo.ToLower().Contains(filter.FilterInfo.ToLower()));
            }

            return(exp);
        }
        private Expression <Func <InternalErrorLogEntryDbModel, bool> > ComposeFilter(ErrorLogsFilter filter)
        {
            var exp = base.ComposeBaseFilter <InternalErrorLogEntryDbModel>(filter);

            if (!string.IsNullOrWhiteSpace(filter.ServiceName))
            {
                exp = PredicateExtensions.And(exp, entry => entry.ServiceName.ToLower().Contains(filter.ServiceName.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.ExceptionTypeName))
            {
                exp = PredicateExtensions.And(exp, entry => entry.ExceptionType.ToLower().Contains(filter.ExceptionTypeName.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.Message))
            {
                exp = PredicateExtensions.And(exp, entry => entry.Message.ToLower().Contains(filter.Message.ToLower()));
            }

            return(exp);
        }
Beispiel #8
0
        // フィルタ条件の取得
        private static Predicate <object> GetFilterPredicate(string pattern, bool isFav)
        {
            var predicates = new List <Predicate <object> >();

            // 指定文字列
            if (!string.IsNullOrEmpty(pattern))
            {
                predicates.Add(obj => (obj as MetaItem).Key.Contains(pattern));
            }

            // お気に入り
            if (isFav)
            {
                predicates.Add(obj => (obj as MetaItem).IsMarking);
            }

            if (predicates.Any())
            {
                return(PredicateExtensions.And(predicates.ToArray()));
            }

            return(null);    // フィルタなし
        }
Beispiel #9
0
        private Expression <Func <TicketDealLogEntryDbModel, bool> > ComposeFilter(DealLogFilter filter)
        {
            var exp = base.ComposeBaseFilter <TicketDealLogEntryDbModel>(filter);

            if (!string.IsNullOrWhiteSpace(filter.TicketId))
            {
                exp = PredicateExtensions.And(exp, entry => entry.TicketId.ToLower().Contains(filter.TicketId.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.OwnerId))
            {
                exp = PredicateExtensions.And(exp, entry => entry.OwnerId.ToLower().Contains(filter.OwnerId.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(filter.RecieverId))
            {
                exp = PredicateExtensions.And(exp, entry => entry.RecieverId.ToLower().Contains(filter.RecieverId.ToLower()));
            }

            if (filter.MinPrice.HasValue)
            {
                exp = PredicateExtensions.And(exp, entry => entry.Price >= filter.MinPrice.Value);
            }

            if (filter.MaxPrice.HasValue)
            {
                exp = PredicateExtensions.And(exp, entry => entry.Price <= filter.MaxPrice.Value);
            }

            if (filter.Type != DealType.Unknown)
            {
                exp = PredicateExtensions.And(exp, entry => filter.Type.HasFlag((DealType)entry.Type));
            }

            return(exp);
        }
Beispiel #10
0
 public void AndFailsWithNullThis()
 {
     Assert.Throws <ArgumentNullException>(() => PredicateExtensions.And(null, _error));
 }