Example #1
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var book = this.db.Books.GetById(id);

            if (book == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "There is no book with id=" + id));
            }

            var bookModel = BookViewModel.CreateFromBook(book);

            return(View(bookModel));
        }
Example #2
0
        public ActionResult Details(int?bookId)
        {
            if (bookId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var book = this.db.Books.GetById(bookId);

            if (book == null)
            {
                return(new HttpNotFoundResult("The book was not found"));
            }

            var model = BookViewModel.CreateFromBook(book);

            return(View(model));
        }