示例#1
0
 public async Task <List <TodoDto> > Handle(GetTodosQuery request, CancellationToken cancellationToken)
 {
     return(await _context.Todos
            .Where(x => request.Query == null ||
                   (
                       x.Content.Contains(request.Query) ||
                       x.Email.Contains(request.Query)
                   )
                   )
            .OrderBy(x => x.Date)
            .ProjectTo <TodoDto>(_mapper.ConfigurationProvider)
            .ToListAsync());
 }
示例#2
0
        public Task <List <Todo> > Handle(GetTodosQuery request, CancellationToken cancellationToken)
        {
            var todos = _context.Todos.Select(t => Mapper.Map <Todo>(t, null)).ToList();

            return(Task.FromResult(todos));
        }