Beispiel #1
0
        public IActionResult GetAuthors(AuthorsResourceParameters authorResourceParameters)
        {
            var authorsFromRepo = _libraryRepository.GetAuthors(authorResourceParameters);

            var authors = Mapper.Map <IEnumerable <AuthorDto> >(authorsFromRepo);

            return(Ok(authors));
        }
Beispiel #2
0
        public IActionResult GetAuthorCollection(
            [ModelBinder(BinderType = typeof(ArrayModelBinder))]
            IEnumerable <Guid> ids)
        {
            if (ids == null)
            {
                return(BadRequest());
            }

            var authorEntities = _libraryRepository.GetAuthors(ids);

            if (ids.Count() != authorEntities.Count())
            {
                return(NotFound());
            }

            var authorsToReturn = Mapper.Map <IEnumerable <AuthorDto> >(authorEntities);

            return(Ok(authorsToReturn));
        }