Esempio n. 1
0
        private IQueryable <Payment> FilterByCategory(IQueryable <Payment> payments, GetPaymentsQuery request)
        {
            if (!request.WithEmptyCategory)
            {
                return(payments);
            }

            return(payments.Where(payment => payment.Category == null));
        }
Esempio n. 2
0
        public async Task <IEnumerable <Payment> > Handle(GetPaymentsQuery request, CancellationToken cancellationToken)
        {
            IQueryable <Payment> payments = _accountingDbContext.Payments;

            payments = FilterByDate(payments, request);
            payments = FilterByPhrase(payments, request);
            payments = FilterByCategory(payments, request);

            return(await payments.ToArrayAsync(cancellationToken));
        }
Esempio n. 3
0
        private IQueryable <Payment> FilterByDate(IQueryable <Payment> payments, GetPaymentsQuery request)
        {
            if (request.DateTo == null && request.DateFrom == null)
            {
                return(payments);
            }

            return(payments.Where(payment =>
                                  (request.DateFrom == null || payment.Date >= request.DateFrom) &&
                                  (request.DateTo == null || payment.Date <= request.DateTo)));
        }
Esempio n. 4
0
        private IQueryable <Payment> FilterByPhrase(IQueryable <Payment> payments, GetPaymentsQuery request)
        {
            var ignoreDetails = string.IsNullOrWhiteSpace(request.WithPhraseInDetails);

            if (ignoreDetails)
            {
                return(payments);
            }

            return(payments.Where(payment => (payment.Details.FullDetails + payment.Details.Alias).Contains(request.WithPhraseInDetails, StringComparison.InvariantCultureIgnoreCase)));
            //return payments.Where(payment => IsDetailsValid(payment, request.WithPhraseInDetails));
        }