Esempio n. 1
0
        public async Task <IEnumerable <ApplicationVM> > Handle(SearchApplicationsQuery request, CancellationToken cancellationToken)
        {
            var normalizedName = request.Name?.ToLowerInvariant();
            Expression <Func <Domain.Applications.Application, bool> > whereExpresion = BuildExpresion(request);
            var result = await _context.Applications.AsNoTracking()
                         .Where(whereExpresion)
                         .ToMap(request.PageSize, request.Page)
                         .ToListAsync(cancellationToken);

            return(result);
        }
Esempio n. 2
0
        private Expression <Func <Domain.Applications.Application, bool> > BuildExpresion(SearchApplicationsQuery request)
        {
            var normalizedName = request.Name?.ToLowerInvariant();
            Expression <Func <Domain.Applications.Application, bool> > whereExpresion = r => r.IsEnabled;

            if (!string.IsNullOrWhiteSpace(normalizedName))
            {
                whereExpresion.And(ap => ap.Name.Contains(normalizedName));
            }
            return(whereExpresion);
        }