public ActionResult Create([Bind(Include = "BookListID,BookListName,BookListType,BookListContent,GenreType")] BookList bookList)
        {
            if (ModelState.IsValid)
            {
                db.BookLists.Add(bookList);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bookList));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "ReviewID,UserID,BookISBN,Rating,Comment")] Review review)
        {
            if (ModelState.IsValid)
            {
                db.Reviews.Add(review);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BookTitle = new SelectList(db.Books, "BookTitle", "AuthorName", review.BookTitle);
            return(View(review));
        }
        public ActionResult Create([Bind(Include = "BookISBN,BookTitle,AuthorName,Genre,GenreType")] Book book)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Books.Add(book);
                    db.SaveChanges();
                    return(RedirectToAction("ViewAllBooks"));
                }
            }
            catch (DuplicateNameException)
            {
                ModelState.AddModelError("", "Unable to save changes. These Book Details already exist");
            }
            //ViewBag.BookName = new ChoiceList(db.Books, "BookISBN", "BookTitle", "AuthorName");


            return(View(book));
        }