Exemplo n.º 1
0
        public IActionResult GetBook(int?id, int?userID, string sessionID)
        {
            if (id == null || userID == null || sessionID == null)
            {
                return(NullValues());
            }
            var user = VerifyUserSessionID(sessionID, userID);

            if (user == null)
            {
                return(InvalidSessionID());
            }
            var bookToReturn = bookDao.GetBook(user, id);

            if (bookToReturn == null)
            {
                return(BadRequest("Book not found or you cannot see this record."));
            }
            return(Ok(bookToReturn));
        }
        //Render page edit book by book id
        public ActionResult Edit(int id)
        {
            //get book need to edit
            var book = BookDao.GetBook(id);

            //store older picture if user don't choose new picture
            oldPicture = book.Picture;
            //get list categories existing and assign for viewbag
            SelectList categories = new SelectList(CategoryDao.GetAllCategory(), "categoryID", "categoryName", book.Category.CategoryName);

            ViewBag.Categories = categories;
            //get list authors existing and assign for viewbag
            SelectList authors = new SelectList(AuthorDao.GetListAuthors(), "authorID", "authorName", book.Author.AuthorName);

            ViewBag.Authors = authors;
            //get list publishers existing and assign for viewbag
            SelectList publishers = new SelectList(PublisherDao.GetListPublisher(), "publisherID", "publisherName", book.Publisher.PublisherName);

            ViewBag.Publishers = publishers;
            return(View("_EditBook", book));
        }
        public ActionResult DetailBookPage(int id)
        {
            Book book = BookDao.GetBook(id);

            ViewBag.Quantity = book.Quantity;
            Cart cart = (Cart)Session[SessionBox.CART_SESSION];

            if (cart != null)
            {
                foreach (var item in cart.ListCartItems)
                {
                    if (item.Book.BookID == book.BookID)
                    {
                        ViewBag.Quantity -= item.Quantity;
                        break;
                    }
                }
            }
            ViewBag.ID = id;
            return(View("Detail", book));
        }
Exemplo n.º 4
0
 public Book GetBook(string bookId)
 {
     return(_bookDao.GetBook(bookId));
 }