public ActionResult <IEnumerable <BookDTO> > GetByGenre(string genre)
        {
            if (string.IsNullOrWhiteSpace(genre))
            {
                return(BadRequest("No se ha reconocido el género"));
            }

            IEnumerable <BookDTO> listBooks = _lib.GetByGenre(genre);

            if (listBooks == null || listBooks.Count() == 0)
            {
                return(NotFound("Género no encontrado"));
            }

            return(Ok(listBooks));
        }
Esempio n. 2
0
        [Produces("application/json")]                        // respuesta es JSON.
        public IActionResult GetByGenre(string genre)
        {
            // Example of read a config value
            // var s = _config.GetValue<string>("EntradaConfigEjemplo");

            if (string.IsNullOrWhiteSpace(genre))
            {
                return(BadRequest());
            }

            IEnumerable <BookDTO> listBooks = _lib.GetByGenre(genre);

            if (listBooks == null || listBooks.Count() == 0)
            {
                return(NotFound());
            }

            return(Ok(listBooks));
        }