public async Task <IList <Author> > Handle(GetAllAuthorsQuery request, CancellationToken cancellationToken) { // load from database IQueryable <AuthorEntity> entities = await _authorsRepository.GetAllAsync(); // map IList <Author> authors = entities.AsEnumerable().Select(AuthorMapper.MapToModel).ToList(); // return return(authors); }
public async Task <IActionResult> Get() { var result = await authorsRepository.GetAllAsync(); if (result == null) { return(NotFound()); } return(Ok(result)); }
public async Task <GetManyAuthorsQueryResult> Handle(GetManyAuthorsQuery request, CancellationToken cancellationToken) { // load from database IQueryable <AuthorEntity> authorEntities = await _authorsRepository.GetAllAsync(request.Skip, request.Take); int totalCount = await _authorsRepository.CountAsync(); // map IList <Author> authors = authorEntities.AsEnumerable().Select(AuthorMapper.MapToModel).ToList(); // return return(new GetManyAuthorsQueryResult(authors, totalCount)); }