Exemple #1
0
        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));
        }
Exemple #3
0
        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));
        }