Ejemplo n.º 1
0
        public ActionResult <AuthorDto> GetAuthor(string authorId)
        {
            if (string.IsNullOrEmpty(authorId))
            {
                throw new ArgumentNullException(nameof(authorId));
            }

            if (!_authorService.AuthorExists(authorId))
            {
                return(NotFound());
            }

            return(Ok(_authorService.GetAuthor(authorId)));
        }
Ejemplo n.º 2
0
        public void AuthorExists()
        {
            var para = new AuthorResourceParameters {
                City = "Salt Lake City", State = "UT"
            };
            var res  = _authorService.GetAuthors(para);
            var resp = _authorService.AuthorExists(res.First().Id);

            Assert.True(resp);
        }
Ejemplo n.º 3
0
        public ActionResult <IEnumerable <BookDto> > GetBooksForAuthor([FromRoute] string authorId)
        {
            if (string.IsNullOrEmpty(authorId))
            {
                throw new ArgumentNullException(nameof(authorId));
            }
            if (!_authorService.AuthorExists(authorId))
            {
                return(NotFound(new AuthorNotFoundException(authorId, null)));
            }

            var res = _bookService.GetBooksForAuthor(authorId);

            if (res == null)
            {
                return(NotFound());
            }

            return(Ok(res));
        }