コード例 #1
0
        public IActionResult GetBook(int bookId)
        {
            if (!repository.Exists(bookId))
            {
                return(NotFound());
            }

            Book book = repository.GetById(bookId);

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

            return(View(book));
        }
コード例 #2
0
        public IActionResult GetCategory(int categoryId)
        {
            if (!repository.Exists(categoryId))
            {
                return(NotFound());
            }

            Category book = repository.GetById(categoryId);

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

            return(Ok(book));
        }
コード例 #3
0
        public IActionResult GetAuthor(int authorId)
        {
            if (!repository.Exists(authorId))
            {
                return(NotFound());
            }

            Author author = repository.GetById(authorId);

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

            //return Ok(author);
            return(View(author));
        }