public async Task <Result <List <CustomerDto> > > Handle(GetCustomersCommand request, CancellationToken cancellationToken) { var customersInDb = await _customerRepository.GetRangeAsync(request.Predicate); var customers = _mapper.Map <List <CustomerDto> >(customersInDb); return(Result <List <CustomerDto> > .Success(customers)); }
public async Task <IActionResult> GetCustomers(string firstName, string lastName, [FromServices] GetCustomersCommand command) { Customer[] customers = await command.Execute(firstName, lastName); if (customers.Length == 0) { return(new NotFoundObjectResult((firstName, lastName))); } return(Ok(customers)); }