Exemple #1
0
        //[ProducesResponseType(400)]
        //[ProducesResponseType(200, Type = typeof(Author))]
        public async Task <IActionResult> GetAll()
        {
            try
            {
                var authors = await _authorsRepository.GetAllAuthors();

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                var authordto = new List <AuthorDto>();
                foreach (var _authors in authors)
                {
                    authordto.Add(new AuthorDto
                    {
                        //AuthorId = _authors.AuthorId,
                        //FirstName = _authors.FirstName
                        //LastName = _authors.LastName
                    });
                }
                return(Ok(authordto));
            }
            catch (Exception ex)
            {
                return(BadRequest($"{ex}, Request not found"));
            }
        }
        private async Task <List <string> > GetAuthorsForBook(int bookId)
        {
            var authors = await _authorsRepository.GetAllAuthors();

            var authorsIds = await _booksAuthorsRepository.GetAuthorsIdsByBookId(bookId);

            return(authors.Where(x => authorsIds.Contains(x.AuthorID)).Select(a => a.FullName).ToList());
        }
Exemple #3
0
        public IActionResult GetAllAuthors()
        {
            var authors = _repository.GetAllAuthors();

            return(Ok(authors));
        }
Exemple #4
0
 public List <Author> GetAllAuthors()
 {
     return(_authorsRep.GetAllAuthors());
 }